2
\$\begingroup\$

I have quaternion representing a camera pose in a coordinate space called "World Frame 2":

  • x+ = right
  • y+ = up
  • z+ = out

...and I want to convert it to another space called "World Frame 1":

  • x+ = right
  • y+ = down
  • z+ = in

(So, y and z are each inverted)

How can I do this conversion?

In another thread, I reasoned it should work like so: (Call this "Approach 1")

When changing the camera coordinate system, we alter the transformation of a 3D point from the world frame to the camera frame. The original transformation from the world to the original camera is:

$$P_{oc} = R \cdot P w + T$$

The transformation from the original camera to Habitat's camera is:

$$P_{hc} = \begin{bmatrix} 1&0& 0 \\ 0& −1& 0 \\ 0 &0& −1 \end{bmatrix} P_{oc} = R_x ( \pi) P_{o c} $$

By combining the above transformations, the translation \$( t_x, t_y, t_z )\$ will change to \$( t_x, − t_y, − t_z )\$, the rotation R will change to \$R_x ( 180 ° ) R\$, and in quaternion form: \$ i \cdot ( w + x i + y j + z k ) = − x + w i − z j + y k \$. Here, i represents a 180-degree rotation around the x-axis.

Another user proposed this: ("Approach 2")

I agree that it's a 180-degree rotation around the x-axis. So the angle axis is:

$$ (\text{angle, axis}) = (\begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}, \pi) $$

If we convert it to quaternion, it should be

$$ q = \begin{pmatrix} \cos(\pi / 2) \\ \sin(\pi / 2) \\ \cos(\pi / 2) \\ \cos(\pi / 2) \end{pmatrix} = \begin{pmatrix}0 \\ 1 \\ 0 \\ 0\end{pmatrix} $$

So the result will be $$q p q^{-1} = [0 1 0 0] [w x y z] [0 1 0 0]^{-1} = [w x -y -z]$$

I asked another user and they linked to this thread ("Approach 3"), which says the resulting quaternion should be:

$$q = w + ix - jy - kz$$

Which one is correct, and why are the others wrong?

\$\endgroup\$
2
  • \$\begingroup\$ @DMGregory Approach 3 didn't appear in the original version of this question and I can't find it in the linked thread. You added it in an edit – Where did you get it from? \$\endgroup\$ Commented Feb 8 at 7:41
  • 1
    \$\begingroup\$ A private conversation with OP on another site. \$\endgroup\$ Commented Feb 8 at 12:46

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.