Using a rotation quaternion and a velocity to transform a point in a cartesian system

779 Views Asked by At

The practical application of the following problem is a control system for aircraft.

I have done a lot of googling and searching this StackExchange looking for an answer but I haven't found anything that seems applicable here. On top of this the wikipedia articles on quaternions go over my head at times.

So, I have a unit quaternion which holds the current rotation of the aircraft and I plan to use a single velocity value and use these together as a velocity vector. The problem I have is that I do not know how to transform the location of the aircraft, which is held as a cartesian vector $(x, y, z)$, using the quaternion and velocity.

I would happily rework the concept if this is not the best way of going about velocity and transformations.

1

There are 1 best solutions below

4
On BEST ANSWER

You can extract the direction something is pointing in from a unit quaternion in the form $\left<\cos\frac\theta2, d_x\sin\frac\theta2,d_y\sin\frac\theta2,d_z\sin\frac\theta2 \right>=\left<q_w,q_x,q_y,q_z\right>$ (first element is the real part, last three elements is the imaginary part) by taking $\sin\cos^{-1}q_w$ and dividing the last three parts by that result to get the direction vector, $\vec d$. From there, your change in position is $s\vec d\Delta t$, where $s$ is the speed.

A few things about quaternions: make sure that you normalize them every so often. The formula to rotate a point is $q*\vec v*q^{-1}=q*\vec v*(q*)$, where $*$ represents quaternion multiplication and $\vec v=\left<0,v_x,v_y,v_z\right>$. $q^{-1}=q*$ is only true for unit quaternions. $q*$ is just the conjugate of $q$.