/usr/share/freemat/toolbox/graph/view.m is in freemat-data 4.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | % VIEW VIEW Set Graphical View
%
% Usage
%
% The view function sets the view into the current plot.
% The simplest form is
%
% view(n)
%
% where n=2 sets a standard view (azimuth 0 and elevation 90),
% and n=3 sets a standard 3D view (azimuth 37.5 and elevation 30).
% With two arguments,
%
% view(az,el)
%
% you set the viewpoint to azimuth az and elevation el.
% Copyright (c) 2002-2006 Samit Basu
% Licensed under the GPL
function view(varargin)
if (nargin == 0)
error('Expected an argument to view function');
end;
if (nargin == 1)
arg = varargin{1};
if (length(arg) == 1)
if (arg == 2)
view(0,90);
return;
elseif (arg == 3)
view(37.5,30);
return;
else
error('Unrecognized form of view');
end
end
else
az = varargin{1};
el = varargin{2};
end
az = az*pi/180;
if el == 0
el = .001;
end
el = el*pi/180;
% The view point is first calculated by transforming to
% spherical coordinates
% Calculate the radius of the cube
xlim = get(gca,'xlim'); xmean = mean(xlim);
ylim = get(gca,'ylim'); ymean = mean(ylim);
zlim = get(gca,'zlim'); zmean = mean(zlim);
xmax = max(abs(xlim-xmean));
ymax = max(abs(ylim-ymean));
zmax = max(abs(zlim-zmean));
r = sqrt(xmax^2+ymax^2+zmax^2);
z = sin(el)*r + zmean;
y = -cos(el)*cos(az)*r + ymean;
x = cos(el)*sin(az)*r + xmean;
set(gca,'cameraposition',[x,y,z]);
if (abs(el-pi/2) < .001)
set(gca,'cameraupvector',[0,1,0]);
else
set(gca,'cameraupvector',[0,0,1]);
end
|