Search code examples
mathlinear-algebra

Decompose a vector in rotational components


Given a random normalized 3D vector, how can I parameterize it with two consecutive rotations of any unit vector around two axes in the cartesian coordinate system?


Solution

  • Consider a starting unit vector u and your random unit vector v.

    Vector u defines a unique circle Cx of all unit vectors who have the same x-coordinate as u, and hence can be reached from u by a rotation around the x-axis.

    Vector v defines a unique circle Cz of all unit vectors who have the same z-coordinate as v, and hence can reach v by a rotation around the z-axis.

    Circles Cx and Cz intersect at two unit vectors. Call w one of these two vectors. Vector w has the same x-coordinate as u and the same z-coordinate as v; you can find its y-coordinate easily because it's a unit vector: wy^2 = 1 - wx^2 - wz^2.

    You can calculate the angles from u to w and from w to v using trigonometry:

    • cos(angle_x(u,w)) = (uy wy + uz wz) / (1 - ux^2)
    • cos(angle_z(w,v)) = (wx vx + wy vy) / (1 - vz^2)

    These trigonometric expressions are found by considering the "dot-product of u and w in the yz-plane" and the "dot-product of w and v in the xy-plane" and noting that the radius of Cx is cos(arcsin(ux))=1-ux^2.