0
$\begingroup$

In my last question, it became clear I could use $v' = q v q^*$ for quaternion coordinate transformation.

However, I believe I've interpreted this incorrectly. Firstly, do I understand correctly that $q$ n this instance is the 4x4 matrix form of the quaternion, not the quaternion vector?

In my example, I have the vector: $$ v = \begin{bmatrix}0 \\0 \\ 20\end{bmatrix}$$

And the quaternion (in form $[w, x,y,z]$) $$ q = \begin{bmatrix}0.7102 \\-0.3828 \\-0.3319 \\0.4887 \end{bmatrix}$$

Which, following $v' = qvq^*$, would result in the equation:

$$v' = \begin{bmatrix}0.7102 & 0.3828 & 0.3319 & -0.4887 \\ -0.3828 & 0.7102 & -0.4887 & -0.3319 \\ -0.3319 & 0.4887 & 0.7102 & 0.3828 \\ 0.4887 & 0.3319 & -0.3828 & 0.7102 \end{bmatrix} \begin{bmatrix}0 \\ 0 \\ 0 \\ 20\end{bmatrix}\begin{bmatrix}0.7102 & -0.3828 & -0.3319 & 0.4887 \\ 0.3828 & 0.7102 & 0.4887 & 0.3319 \\ 0.3319 & -0.4887 & 0.7102 & -0.3828 \\ -0.4887 & -0.3319 & 0.3828 & 0.7102\end{bmatrix}$$

This results in the vector:

$$v' = \begin{bmatrix}-13.88 \\ -9.43 \\ 10.88 \\ 0.18 \end{bmatrix}$$

I would expect the last three elements of this vector to represent my transformed vector. Yet the vector has a w component, indicating the vector has been transformed into the fourth dimension, and taking only the 3d components would not work. Thus do I need to perform some kind of projection into 3D space of this 4D vector, in order to end up with $v'$?

$\endgroup$
  • $\begingroup$ In the answer to that other question, the author writes that it’s a quaternion product. Perhaps you missed or misinterpreted that. $\endgroup$ – amd Apr 6 '18 at 23:36
  • $\begingroup$ Indeed I did. Could you explain the quaternion product or point me to reference for it? I'm not sure how I'd go about implementing the quaternion product with something like numpy. Does it take the vector form of the quaternion, the 2x2 matrix form, or the 4x4 matrix form? $\endgroup$ – Nate Gardner Apr 9 '18 at 19:13
  • $\begingroup$ Would this be the correct implementation of the quaternion product, given q1 and q2 with components x,y,z,w? w' = w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2 x' = w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2 y' = w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2 z' = w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2 $\endgroup$ – Nate Gardner Apr 9 '18 at 19:56
  • $\begingroup$ I find it easier to remember the product by dividing the quaterions into their scalar and vector parts, so $(r_1,\mathbf v_1)(r_2,\mathbf v_2) = (r_1r_2-\mathbf v_1\cdot\mathbf v_2, r_1\mathbf v_2+r_2\mathbf v_1+\mathbf v_1\times\mathbf v_2)$. Historically, this is the origin of the dot and cross products of vectors. See en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts for more. $\endgroup$ – amd Apr 9 '18 at 20:02
  • $\begingroup$ So translating to the notation I'm using, r is the w component of the quaternion 4d vector? (i.e. a in a + bi + cj +dk)? $\endgroup$ – Nate Gardner Apr 9 '18 at 20:37
1
$\begingroup$

For the sake of not leaving questions unanswered, I’ll sum up the comments here.

It looks like you’ve mistaken a quaternion product for a matrix product in the answer to the linked question. The product of two quaternions is just the result of applying the distributive law of multiplication over addition and the rules for the products of the basis quaternions $\mathbf i$, $\mathbf j$ and $\mathbf k$ to the algebraic product of quaternions of the form $a+b\mathbf i+c\mathbf j+d\mathbf k$. I find it easier to remember what the final result looks like if I separate the quaternions into their scalar and vectors parts, $r=a$ and $\vec v=(b,c,d)$, respectively. The quaternion product then looks like $$(r_1,\vec v_1)(r_2,\vec v_2)=(r_1r_2-\vec v_1\cdot\vec v_2,r_1\vec v_2+r_2\vec v_1+\vec v_1\times\vec v_2).$$ Historically, this product was a motivation for the definition of the dot and cross products of vectors.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.