How to rotate about an axis parallel to x axis?

5 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

John D'Errico
John D'Errico il 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.
  1 Commento
yunya liu
yunya liu il 28 Apr 2022
Really helpful. That's what I'm looking for. I previously only did rotation about origin point not around specific axis. Thanks very much.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Vector Fields in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by