Correct sign of rotation for projection of 3D points, matlab
I have a set of 3D points which I am projecting to image plane.
I am getting problem with rotation matrix. Any help would be great. Be开发者_开发问答low is my code in matlab,
% adjusted plane through points XYZ=[X,Y,Z]p*3 % where p is no of points
%n*(XYZ)-d=0; Given plane parameters
-0,946467797198737 0,322785394989535 0,00288056369821191 28,3620026340107
% finding rotation matrix for [ 0 0 1]% xy plane projection
[U, S, V]= svd(n);
C= [U(:, 2: 3), n];
R= rref([C, eye(3)]);
R= R(:, 4: 6);
% Test for correct R % R*n
R*n=[ -0.0000, - 0, 1.0000]'
My question is about sign. Any method to get the correct sign ? I don't want to play with answer.(R*n). Problem is to get such R which gives you correct answer.
Well, actually your problem may not be so bad as it looks like.
More or less you still have a unit vector along z
-axis. Just proceed your computations and ignore this kind of details (unless you really know how they may affect your computations, please note also that quite often a combination of inaccurate computations tends to balance themselves).
But if you really want (or need) delve in the details, just fine tune your computations like:
>>> x= [-1e-13 1e-13 1]';
>>> x(abs(x)< 1e-12)= 0
x =
0
0
1
Update:
The sign
you should worry about is the det(R)
, thus you should add a check like:
>>> if 0> sign(det(R)), R= -1* R; end
精彩评论