How to rotate about an axis parallel to x axis?
14 views (last 30 days)
I'm trying to rotate a vector around one axis parallel to x axis.
To my understanding, the rotation around x axis in 3d space is by applying:
a = 1;
xcord = [0 a]; ycord = [0 0]; zcord = [0 0];
pos = [xcord; ycord; zcord];
theta = 30;
Rot = [1, 0, 0; 0, cosd(theta), -sind(theta); 0, sind(theta), cosd(theta)];
pos_new = Rot*pos;
This follows the axis-angle representation of rotating about x axis. But what if I want to rotate about an axis parallel to x axis?
Thanks in advance.
John D'Errico on 28 Apr 2022
Simple. Effectively, you transform the problem to a rotation around the x axis, then after the rotation, you tranform back.
For example, suppose you want to rotate around an "axis" that lives along the coordinates [x 1 2]? This is parallel to the x axis. Think of the x axis as the set of points [x 0 0].
Given your points in pos, you would then do:
axisvec = [0 1 2]';
rotatedpos = axisvec + Rot*(pos - axisvec)
This does exactly as I said. It translates the points so that the new origin is the point [0 1 2]. Then it perform the rotation. Then it translates the coordinates system back to the original domain.