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?
Update: 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?
Try the same in Matlab 2013a .. you will find the results matching the expectation ...I don't know which version of Matlab you are using .. but it is certainly fixed in version 8.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With