Matlab 3D view matrix
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Let A be MATLAB's 4x4 view matrix, obtained from the view function by:
A = view;
A(1:3,1:3) should correspond to rotation and scaling, A(1:3,4) should correspond to translation, and A(4,:) should simply be [0 0 0 1].
When setting the camera parameters to the following simple scenario:
camproj('orthographic')
set(gca, 'CameraPosition', [0,0,0])
set(gca, 'CameraTarget', [0,0,1])
set(gca, 'CameraUpVector', [0,1,1])
I get that A = view is:
-1 0 0 0.5
0 1 0 -0.5
0 0 1 -0.5
0 0 0 1
Now I can't figure our where the 0.5's are coming from. Note that I set the camera position to [0,0,0] so there should be no translation.
Another peculiarity, setting the camera position to [0,0,10] by:
set(gca, 'CameraPosition', [0,0,10])
results in the A:=view matrix becoming
1 0 0 -0.5
0 1 0 -0.5
0 0 -1 5.5
0 0 0 1
So I've noticed the -0.5 has changed to 5.5 in A(3,4) and this somehow has to do with 5 = 10 / 2. That is, changing the camera position to [0,0,a] changes the view matrix at A(3,4) by roughly a / 2.
This is... weird? Peculiar? Odd?
Yet another pecularity is that the determinant of A(1:3,1:3) is -1 although for a rotation matrix it should be 1. When it's -1 it means that it's not only rotation but also reflection. Why would we need reflection?
0 Kommentare
Antworten (1)
Patrick Kalita
am 31 Mai 2012
The matrix returned by view isn't terribly useful unless the axes' stretch-to-fill behavior has been turned off. Probably the easiest way to turn it off is to call axis vis3d. If you call that before your example, you get the answer you'd expect:
axis vis3d
camproj('orthographic')
set(gca, 'CameraPosition', [0,0,0])
set(gca, 'CameraTarget', [0,0,1])
set(gca, 'CameraUpVector', [0,1,1])
Now...
>> A = view
A =
-1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
FYI, another way of disabling the stretch-to-fill behavior is to set the CameraViewAngle property, as mentioned here.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!