# Qdot from 2 quaternions

## Recommended Posts

Hi guys

I have a bit of a challenge here. I am attempting to determine body rotation rates from 2 Tait-Bryan angles.

I have each set of angles converted to a quaternion, and the time step dt. I know that the formula for obtaining body rotation rates is 2*(qd/dt)*inverse of q. My question is, how do I determine qd/dt from 2 orientation quaternions, and which quaternion I would invert.

Thanks

JB

##### Share on other sites

You nearly got it and are on the right track. Say we have a start quaternion q1 and a target quaternion q2.  We start from the quaternion derivative:

dq/dt = 0.5 * w * q

This can be approximated using the differential quotient:

(q2 - q1) / dt = 0.5 * w * q1

Solving for w yields:

w = 2 * (q2 - q1) / dt * conjugate( q1 )

The angular velocity omega is now the vector (imaginary) part of the (pure) quaternion w:

Vector3 omega = w.imgaginary();

There is a small gotcha here. Since you are subtracting quaternions, you need to make sure that q1 and q2  are in the same hemisphere. You can check polarity simply by using the dot product.

if ( dot( q1, q2 ) < 0 )
{
q1 = -q1
}

Edited by Dirk Gregorius

##### Share on other sites

Thanks a bunch. Once I have sorted out the polarity I take it I just subtract each individual element in the quaternion?

And dividing by dt I take it is again simply dividing each individual element by dt?

Edited by Naruto-kun

##### Share on other sites

Correct! Quaternion addition/subtraction and scalar multiplication are per element. Just like a 4D vector.

## Create an account

Register a new account

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633427
• Total Posts
3011818
• ### Who's Online (See full list)

There are no registered users currently online

×