Skip to main content
Fixed a copy paste error in the formulae for the rotation matrices.
Source Link
     ┌ cosθ  -sinθ   0 ┐
Rz = │ sinθ   cosθ   0 │
     └   0      0    1 ┘
     ┌  1    0     0   ┐
Rx = │  0  cosθ  -sinθ │
     └  0  sinθ   cosθ ┘

     ┌  cosθ  0   sinθ ┐
Ry = │   0    1   0   
     └ -sinθ  0  cosθ    1    0     0   ┐┌  cosθ  0  sinθ ┐
Rx =   0  cosθ  -sinθ ││   0    1   0   │  0  sinθ   cosθ ┘└ -sinθ  0   cosθ ┘
     ┌ cosθ  -sinθ  0 ┐
Rz = │ sinθ   cosθ  0 │
     └   0      0   1 ┘
     ┌  1    0     0   ┐
Rx = │  0  cosθ  -sinθ │
     └  0  sinθ   cosθ ┘

     ┌  cosθ  0  sinθ ┐
Ry = │   0    1   0   
     └ -sinθ  0  cosθ    1    0     0   ┐┌  cosθ  0  sinθ ┐
Rx =   0  cosθ  -sinθ ││   0    1   0   │  0  sinθ   cosθ ┘└ -sinθ  0  cosθ ┘
     ┌ cosθ  -sinθ   0 ┐
Rz = │ sinθ   cosθ   0 │
     └   0      0    1 ┘
     ┌  1    0     0   ┐
Rx = │  0  cosθ  -sinθ │
     └  0  sinθ   cosθ ┘

     ┌  cosθ  0   sinθ ┐
Ry = │   0    1    0   │
     └ -sinθ  0   cosθ ┘
Correct row 2 column 1 in concatenated rotation matrix
Source Link
Chris
  • 221
  • 2
  • 4
         ┌      CyCz              -CySz        Sy  ┐
RxRyRz = │  SxSySzSxSyCz + CxSz   -SxSySz + CxCz   -SxCy │
         └ -CxSyCz + SxSz    CxSySz + SxCz    CxCy ┘
         ┌      CyCz              -CySz        Sy  ┐
RxRyRz = │  SxSySz + CxSz   -SxSySz + CxCz   -SxCy │
         └ -CxSyCz + SxSz    CxSySz + SxCz    CxCy ┘
         ┌      CyCz              -CySz        Sy  ┐
RxRyRz = │  SxSyCz + CxSz   -SxSySz + CxCz   -SxCy │
         └ -CxSyCz + SxSz    CxSySz + SxCz    CxCy ┘
Correct incorrect array indices.
Source Link
Chris
  • 221
  • 2
  • 4

Let's first get the x angle out. If we know the sin(x) and cos(x), we can use the inverse tangent function atan2 to give us back our angle. Unfortunately, those values don't appear by themselves in our matrix. But, if we take a closer look at elements M[1][3]M[1][2] and M[2][3]M[2][2], we can see we do know -sin(x)*cos(y) as well as cos(x)*cos(y). Since the tangent function is the ratio of the opposite and adjacent sides of a triangle, scaling both values by the same amount (in this case cos(y)) will yield the same result. Thus,

Let's first get the x angle out. If we know the sin(x) and cos(x), we can use the inverse tangent function atan2 to give us back our angle. Unfortunately, those values don't appear by themselves in our matrix. But, if we take a closer look at elements M[1][3] and M[2][3], we can see we do know -sin(x)*cos(y) as well as cos(x)*cos(y). Since the tangent function is the ratio of the opposite and adjacent sides of a triangle, scaling both values by the same amount (in this case cos(y)) will yield the same result. Thus,

Let's first get the x angle out. If we know the sin(x) and cos(x), we can use the inverse tangent function atan2 to give us back our angle. Unfortunately, those values don't appear by themselves in our matrix. But, if we take a closer look at elements M[1][2] and M[2][2], we can see we do know -sin(x)*cos(y) as well as cos(x)*cos(y). Since the tangent function is the ratio of the opposite and adjacent sides of a triangle, scaling both values by the same amount (in this case cos(y)) will yield the same result. Thus,

Correct information on how to calculate z. Previous answer did not take the inverse of the RxRy rotation matrix.
Source Link
Chris
  • 221
  • 2
  • 4
Loading
Source Link
Chris
  • 221
  • 2
  • 4
Loading