Calculate rotation matrix that flips the frame up

1.3k Views Asked by At

Let's start with the standard basis frame: [1, 0, 0], [0, 1, 0], and [0, 0, 1].

Imagine this frame goes through some arbitrary rotation R, with one constraint, that we know that after the R is applied to the frame, the z-axis becomes [0, 0, -1].

I want to calculate a rotation that "flips" the [0, 0, -1] back to the [0, 0, 1] vector with the smallest angle possible. Note: Inverting the R is NOT correct, because we want the smallest angle, and inverting R would always completely erase the rotation to give us the identity matrix.

The top answer here: Calculate Rotation Matrix to align Vector A to Vector B in 3d? does not apply, because I am describing the edge case that Jur van den Berg says is not supported.

Geometrically, if we start with the orientation corresponding with the z-axis at [0, 0, -1], I think to "flip" the frame we need to swap the corresponding x and y axises, and simply multiply [0, 0, -1] by -1 to get [0, 0, 1]. You can understand what I'm saying if you use your hand to form a frame by right hand rule, then 'flip' your thumb to negate the z-axis, and then 'flip' it back. How do I calculate this 'flip' relative rotation for any arbitrary orientation?

2

There are 2 best solutions below

6
On

To do the rotation that you need, choose any axis perpendicular to the z-axis, and rotate by $\pi$. All of the rotations will get you there and cannot be distinguished by the "size" of the rotation as the angles are all the same.

10
On

To expand a bit on tpofofn's answer, there is an infinite number of such transforms, described by a 180° rotation around an unix axis vector $\hat{a}$, $$\hat{a} = \left [ \begin{matrix} \cos\varphi \\ \sin\varphi \\ 0 \end{matrix} \right ]$$

In other words, all rotation matrixes of form $$\mathbf{R} = \left [ \begin{matrix} \cos\varphi & \sin\varphi & 0 \\ \sin\varphi & -\cos\varphi & 0 \\ 0 & 0 & -1 \\ \end{matrix} \right ]$$ will work. $\varphi$ only determines the direction of the rotation axis on the $x y$ plane.

By OP's own metric, all these rotation matrices are equally preferable, because they rotate by angle $\theta = 180°$; only the axis around which we rotate changes.