# Coordinate Transformation of 3D Vector Using Quaternion Vector

Given a vector in a reference frame and a quaternion $\mathbf{q} = [q_x,q_y,q_z,q_w]$ that represents the rotation between my initial reference frame and my reference frame of interest:

First, where $\mathbf{q}$ is the quaternion vector that represents the rotation between the two reference frames, is the following a valid coordinate transformation between the two systems?

$$\begin{bmatrix}x' \\y' \\z' \end{bmatrix} = \begin{bmatrix}1-2q_y^2-2q_z^2 & 2q_x q_y-2q_zq_w & 2q_xq_z + 2q_yq_w \\2q_xq_y+2q_zq_w & 1-2q_x^2-2q_z^2 & 2q_yq_z-2q_xq_w \\2q_xq_z-2q_yq_w & 2q_yq_z+2q_xq_w & 1-2q_x^2-2q_y^2 \end{bmatrix} \begin{bmatrix}x\\y\\z \end{bmatrix}$$

where $[x',y',z']$ is the same vector as $[x,y,z]$ represented in the reference frame rotated by $\mathbf{q}$.

Next, is there a way to perform a coordinate transformation of a 3D vector between two reference frames given a quaternion representing the rotation between the reference frames without converting the quaternion to a rotation matrix?

That is, if I have some 3D point and I want to express that same point in a coordinate system rotated by my quaternion, what is the equation to perform a coordinate transform on that point?

Correct, that matrix is representing the quaternion rotation.

Yes, you can perform rotations with quaternions without converting quaternions to matrices. Since you can embed your Euclidean 3D vectors into quaternion 4D linear space, just considering the $q_w=0$, you can rotate your vectors using quaternion product:

$v' = q v q^*$

Where $q^*$ is the conjugate quaternion. Then you can map back the rotated 4D vector $v'$ to the 3D space.

• So I simply take my vector $[x,y,z]$ and make it $[x,y,z,0]$, then perform that multiplication? Awesome! – Nate Gardner Feb 23 '18 at 22:14
• Yes, as simple as it sounds. – Mauricio Cele Lopez Belon Feb 24 '18 at 1:10
• The quaternion needs to be in its matrix representation, not its vector representation, I take it? – Nate Gardner Apr 6 '18 at 19:03
• I'm a little confused: see followup – Nate Gardner Apr 6 '18 at 22:00
• @NateGardner No. The answer says “quaternion product,” not “matrix product.” Part of the point of using quaternion in computation is to avoid the full cost of matrix multiplications. – amd Apr 6 '18 at 23:37