I have rotation matrix which is not orthogonal. Whats wrong. I can’t get it.
Exterior=[-6.6861,12.6118,-8.0660,[-0.4467,-0.3168,0.2380]*pi/180];%# deg 2 rad
%#data
ax=Exterior(4);
by=Exterior(5);
cz=Exterior(6);
%#Rotation in X
Rx = [1 0 0
0 cos(ax) -sin(ax)
0 sin(ax) cos(ax)];
%#Rotation in Y
Ry = [cos(by) 0 sin(by)
0 1 0
-sin(by) 0 cos(by)];
%#Rotation in Z
Rz = [cos(cz) -sin(cz) 0
sin(cz) cos(cz) 0
0 0 1];
R=Rx*Ry*Rz;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R =
0.99998 -0.0041538 -0.0055292
0.0041969 0.99996 0.0077962
0.0054966 -0.0078192 0.99995
Orthogonality check
Inv(R)-R'=
2.2204e-016 2.6021e-018 8.6736e-019
0 1.1102e-016 -1.7347e-018
-2.6021e-018 3.4694e-018 2.2204e-016
R*R'=
2.2204e-016 2.6021e-018 8.6736e-019
0 1.1102e-016 -1.7347e-018
-2.6021e-018 3.4694e-018 2.2204e-016
Why there is different signs.???????
Any mistake??
Looks like the numbers in your orthogonality check are just due to rounding errors… They’re really quite tiny.
There is an error in the question, pointed out by @ChisA. The OP pasted the same matrix for
inv(R)-R'andR*R'If we reconstruct the input file:
And run in through Octave (I don’t have MATLAB):
Notice the
R*R'is very close toIandinv(R)-R'is very close to0.Notice also that I get different small values than the OP. Because I am using a different piece of software the rounding errors will be different. So you should never rely on an exact comparison between two floating point numbers. You always should include some tolerance.
I hope this makes things a little clearer. See the comment by @gnovice below for links to more detailed information about rounding errors.