旋转矩阵不是正交的

Sha*_*gee 3 matlab

我有旋转矩阵,它不是正交的.怎么了.我无法得到它.外部= [ - 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;
Run Code Online (Sandbox Code Playgroud)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  0.99998   -0.0041538   -0.0055292
0.0041969      0.99996    0.0077962
0.0054966   -0.0078192      0.99995
Run Code Online (Sandbox Code Playgroud)

正交检查

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

为什么会有不同的迹象.???????

有什么错吗?

idz*_*idz 11

看起来你的正交检查中的数字只是因为舍入误差......它们真的非常小.

@ChisA指出,问题中存在错误.OP为inv(R)-R'和粘贴了相同的矩阵R*R'

如果我们重建输入文件:

Exterior = [-6.681,12.6118,-8.0660,[-0.4467,-03168,0.2380]*pi/180]

ax = Exterior(4)
by = Exterior(5)
cz = Exterior(6)

Rx = [1 0 0 ; 0 cos(ax) -sin(ax) ; 0 sin(ax) cos(ax)]
Ry = [cos(by) 0 sin(by) ; 0 1 0 ;  -sin(by) 0 cos(by)]
Rz = [cos(cz) -sin(cz) 0 ; sin(cz) cos(cz) 0 ; 0 0 1]

R = Rx*Ry*Rz

inv(R)-R'

R*R'
Run Code Online (Sandbox Code Playgroud)

并通过Octave运行(我没有MATLAB):

Exterior =

  -6.6810e+00   1.2612e+01  -8.0660e+00  -7.7964e-03  -5.5292e+01   4.1539e-03

ax = -0.0077964
by = -55.292
cz =  0.0041539
Rx =

   1.00000   0.00000   0.00000
   0.00000   0.99997   0.00780
   0.00000  -0.00780   0.99997

Ry =

   0.30902   0.00000   0.95106
   0.00000   1.00000   0.00000
  -0.95106   0.00000   0.30902

Rz =

   0.99999  -0.00415   0.00000
   0.00415   0.99999   0.00000
   0.00000   0.00000   1.00000

R =

   0.3090143  -0.0012836   0.9510565
  -0.0032609   0.9999918   0.0024092
  -0.9510518  -0.0038458   0.3090076

ans =

  -5.5511e-17   1.3010e-18   1.1102e-16
   2.1684e-19   0.0000e+00  -4.3368e-19
  -1.1102e-16  -4.3368e-19  -5.5511e-17

ans =

   1.0000e+00  -1.9651e-19  -4.6621e-18
  -1.9651e-19   1.0000e+00   8.4296e-19
  -4.6621e-18   8.4296e-19   1.0000e+00
Run Code Online (Sandbox Code Playgroud)

注意R*R'非常接近I并且inv(R)-R'非常接近0.还要注意的是,我得到不同的小的值比OP.因为我使用的是不同的软件,所以舍入错误会有所不同.因此,您永远不应该依赖两个浮点数之间的精确比较.你总是应该包括一些容忍度.

我希望这会让事情变得更加清晰.请参阅下面的@gnovice的评论,以获取有关舍入错误的更多详细信息的链接.

  • @shahbaba:使用[double precision](http://en.wikipedia.org/wiki/Double_precision_floating-point_format)数字时,第16位有效数字的错误肯定是浮点舍入误差,这些可以在任一方向发生(正面或负面).有关更多信息,请查看[此相关问题](http://stackoverflow.com/q/686439/52738),[本文](http://download.oracle.com/docs/cd/E19957-01/ 806-3568/ncg_goldberg.html)和[此MATLAB文档](http://www.mathworks.com/help/techdoc/ref/eps.html). (4认同)
  • 我不知道为什么他们会有相同的标志. (2认同)