3

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?

user3180
  • 699

2 Answers2

2

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.

Glärbo
  • 286
  • @Widawensen: Thanks, fixed now. – Glärbo Jan 15 '21 at 16:59
  • Now we can see that $tr(R)=-1= 1+2\cos(\theta)$ hence $\cos(\theta)=-1$ which properly leads to $\theta = \pi$ solution. – Widawensen Jan 15 '21 at 17:05
  • So, how can we choose one of these transforms consistently? The motivation is Figure 3 of this paper: https://arxiv.org/pdf/1908.07640.pdf – user3180 Jan 15 '21 at 18:49
  • Also, in section 3.2, when they talk about "change of basis" – user3180 Jan 15 '21 at 18:49
  • Basically, in that paper they define an operator that maps rotations producing the same "image" of an object to one canonical rotation, but this map is only defined for the standard z-axis. If the object is rotated so that the z-axis is transformed, how do we "undo" the transformation consistently such that we perform change of basis correctly? – user3180 Jan 15 '21 at 18:50
  • @user3180: Consider different values of $\varphi$ (defining the direction of the rotation axis on the $x y$ plane). If $\varphi = 0$, the image gets flipped along the $y$ axis. If $\varphi = 90°$, the image gets flipped along the $x$ axis. For any value of $\varphi$, the image gets flipped along the 2D axis $(\sin\varphi, -\cos\varphi)$. Now, $\mathbf{R}$ that was applied already, must also correspond to a value of $\varphi$, because all rotations that rotate $(0, 0, 1)$ to $(0, 0, -1)$ do. So, the question is, [...] – Glärbo Jan 15 '21 at 20:29
  • @user3180: [...] Does the original $\mathbf{R}$ (that we are not supposed to reverse exactly, only to map $(0,0,-1)$ back to $(0,0,1)$) contain information we could use to choose the $\varphi$ for the reversing rotation matrix? I do not believe it does. The article itself says it is a problem, and for this reason, they instead concentrate on a subset of possible rotations, by angles between $-25.5°$ and $+67.5°$, and optionally combining two such rotations to cover the entire parameter space of SO(3) rotations. Which makes sense, in my opinion. – Glärbo Jan 15 '21 at 20:33
  • Where does the article say that is the problem? – user3180 Jan 16 '21 at 22:47
  • When we talk about this "partial reversing" / "change of basis" matrix we are referring to aligning the transformed z-axis with [0, 0, 1]. The article says when you are trying to "canonicalize" a rotation around the z-axis, there is a problem of discontinuity at 90 degrees. But as far as I can tell it says nothing about there being a problem doing the change of basis – user3180 Jan 16 '21 at 22:49
  • @user3180: Figure 3. You are at the center of the "hazardous region" by trying to find a rotation by 180° degrees that maps to a desired pose. The ambiguity is the same, and you are exactly at the discontinuity point that is the reason for the "hazardous region". For you, the binary choice there is here expanded to an entire extra degree of freedom (axis of rotation in the $x y$ plane, i.e. $\varphi$). – Glärbo Jan 18 '21 at 13:00
0

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.

Tpofofn
  • 4,771
  • But the choice of rotation axis affects what happens to the transformed XY axes right. Although any axis affects the z-axis correctly, XY will be affected incorrectly – user3180 Jan 15 '21 at 12:37
  • I believe the correct behavior for XY will be to swap X and Y, like i stated above – user3180 Jan 15 '21 at 12:37
  • @user3180, yes, that is a valid rotation which gets you what you want. The problem is that your criteria "with the smallest angle possible" is unclear. I interpreted your intent to be in terms of axis-angle definition. I think you have something else in mind. – Tpofofn Jan 15 '21 at 13:18
  • Your approach basically rotates by $\pi$ about the $x=y$ line in the $x-y$ plane, which is $\perp$ to the z-axis. – Tpofofn Jan 15 '21 at 13:19
  • So, the motivation for this is, I am trying map an arbitrary rotation to a z-axis rotation. such that I can break the symmetry according to to Figure 3 here: https://arxiv.org/pdf/1908.07640.pdf – user3180 Jan 15 '21 at 16:20
  • So, maybe with just the new and old z-axis, we cannot do this mapping in a consistent way. But what if we also had the orientation itself? How would we do it? – user3180 Jan 15 '21 at 16:22