0
$\begingroup$

I want to rotate a point (3,4,5) by an angle 45 degrees(0.785398 rad) in 3D space. I have used the standard DCM matrix in the order Rx, Ry and Rz. Where,

$\theta = 0.785398 [rad]$

$$ Rx= \begin{bmatrix} 1& 0& 0\\ 0& cos(\theta)& sin(\theta)\\ 0& -sin(\theta)& cos(\theta)\\ \end{bmatrix}$$

$$ Ry= \begin{bmatrix} cos(\theta)& 0& -sin(\theta)\\ 0& 1& 0\\ sin(\theta)& 0& cos(\theta)\\ \end{bmatrix}$$

$$ Rz=\begin{bmatrix} cos(\theta)& sin(\theta)& 0\\ -sin(\theta)& cos(\theta)& 0\\ 0& 0& 1 \\ \end{bmatrix}$$

Rz= ([ cos(theta), sin(theta), 0 ] [ -sin(theta), cos(theta) , 0] [ 0,0,1 ])

$$R(\theta) = Rx(\theta)* Ry(\theta)* Rz(\theta)$$ $$x_{rotated} = R(\theta) * x$$

We get a 3 x 1 matrix after this multiplication. The resultant matrix for the value of X,Y and Z is found by adding all the values in this case I got

X = [[ 1.50000049]
[-0.43934]
[ 2.56065985]] 
therefore X= 3.62

y = R * y
Y = [[ 2]
[ 3.41421352]
[-0.58578667]] 
therefore Y= 4.82

z = R * z
Z = [[-3.53553333]
[ 2.5  ]
[ 2.50000082]]
therefore Z= 1.46

Ideally even after the rotation of the point the length of the point from origin should remain the same but here it is varying. Length before rotation is 7.071 and length after rotation is 6.210.Could you tell me if anything is wrong.

My basic idea is to rotate the 3D point independently along the three axis by a certain angle to get the new position of of the same point now when the axis are rotated by certain angle. Please suggest some approach.

$\endgroup$
5
  • $\begingroup$ Yes. If what you did is something like $R_z\cdot R_y\cdot R_x \cdot \vec p$, and the three matrices are rotation matrices. $\endgroup$
    – AJN
    Commented Mar 9, 2023 at 14:38
  • 1
    $\begingroup$ Please add the three matrices in the question using the edit option. Looks like the range from origin doesn't match. $\endgroup$
    – AJN
    Commented Mar 9, 2023 at 15:27
  • $\begingroup$ Yes I followed the similar approach.I dont find a way to verify the same.Basically I want to rotate the point independently by a certain angle to get the position of same point now when each axis is rotated by a certain angle $\endgroup$ Commented Mar 9, 2023 at 15:29
  • $\begingroup$ The rotations I am considering are taking place simultaneosly $\endgroup$ Commented Mar 9, 2023 at 15:31
  • $\begingroup$ I have not fully understood your question. Please add more details of what you did and what you want to know. Directly in the question using the edit option. $\endgroup$
    – AJN
    Commented Mar 9, 2023 at 18:16

1 Answer 1

0
$\begingroup$
theta = 0.785398,

 Rx= [ 1, 0, 0;
   0, cos(theta), sin(theta);
   0, -sin(theta), cos(theta)];

 Ry= [ cos(theta), 0, -sin(theta);
       0, 1, 0;
      sin(theta), 0, cos(theta)];

Rz= [ cos(theta), sin(theta), 0 ;
        -sin(theta), cos(theta) , 0;
        0,0,1 ];

Rx * Rx.'
   1.0000        0        0
        0   1.0000  -0.0000
        0  -0.0000   1.0000

Ry * Ry.'
   1.0000        0   0.0000
        0   1.0000        0
   0.0000        0   1.0000

Rz * Rz.'
   1.0000  -0.0000        0
  -0.0000   1.0000        0
        0        0   1.0000

The individual matrices appear to be constructed correctly since multiplying them with their own transpose yields identity matrices.

I want to rotate a point (3,4,5) by an angle 45 degrees(0.785398 rad) in 3D space

This is a vague statement. Usually, when a point and an angle is given, an axis of rotation also needs to be specified. The above statement doesn't mean that we can construct three matrices with the same parameter $\theta$ and then apply all three matrices on the point.

However, assuming that this is actually what you want to do (it probably isn't),

R = Rx * Ry * Rz
   0.5000   0.5000  -0.7071
  -0.1464   0.8536   0.5000
   0.8536  -0.1464   0.5000

result=R * [3;4;5]
  -0.035533
   5.474874
   4.474874

norm([3;4;5]) = 7.071
norm(result)  = 7.071

The distance from origin are matching.

X = [[ 1.50000049]
[-0.43934]
[ 2.56065985]] 
therefore X= 3.62

How did you arrive at these numbers ? You don't need three steps to construct the result. It could have been obtained in a single step as I have shown above.

$\endgroup$