view1
campos([3 15 3]);
camtarget([3 0 2]);
camup([0 0 1]);
camproj('perspective');
camva(40);
h = gca;
fprintf('camera position: %g %g %g\n',get(h,'CameraPosition'));
fprintf('camera target: %g %g %g\n',get(h,'CameraTarget'));
fprintf('camera up vector: %g %g %g\n',get(h,'CameraUpVector'));
projection = get(h,'Projection');
if (strcmp(projection,'perspective'))
fprintf('camera view angle: %g\n',get(h,'CameraViewAngle'));
end
fprintf('projection: %s\n',projection);
[az el] = view();
if az>180
az = az - 360;
end
fprintf('az %g el %g\n',az,el);
fprintf('view matrix\n');
T = viewmtx(az,el);
disp(T)
camera position: 3 15 3
camera target: 3 0 2
camera up vector: 0 0 1
camera view angle: 40
projection: perspective
az 180 el 3.81445
view matrix
-1.0000 0.0000 0 0
-0.0000 -0.0665 0.9978 0
0.0000 0.9978 0.0665 0
0 0 0 1.0000
RC = T(1:3,1:3);
RC(2:3,:) = -RC(2:3,:)
RM = [0 1 0; -1 0 0; 0 0 1];
RM*RC
RC =
-1.0000 0.0000 0
0.0000 0.0665 -0.9978
-0.0000 -0.9978 -0.0665
ans =
0.0000 0.0665 -0.9978
1.0000 -0.0000 0
-0.0000 -0.9978 -0.0665