Maths - Quaternion Calculus

Quaternion Differentiation with respect to Scalar

To differentiate a quaternion with respect to a scalar, say 'x', we individually differentiate each element with respect to 'x'. So if:

f(x) = a + b i + c j + e k

then:

d f(x) / dx = d(a /dx) + d(b/dx) i + d(c/dx) j + d(e/dx) k

So to give a more specific example if:

f(x) = xn + sin(x) i + tan(x) j + ex k

then:

d f(x) / dx = n*xn-1 + cos(x) i + sec2(x) j + ex k

So this is quite simple, provided that we can differentiate the elements of a quaternion, we can differentiate the whole quaternion.

Quaternion Differentiation with respect to another Quaternion

Since division of one quaternion by another will give a result for non-zero values (unlike vectors) we can define differentiation with respect to another quaternion.

What are the rules of such differentiation? What applications does it have?

gears

Could we use it in this situation? Imagine that two quaternions represent the angular position of two gears, can we differentiate one with respect to another to get the ratio of the gears?

Applications

Here we go back to the simple case of differentiation with respect to scalars, when we start to look at applications it becomes less simple.

For instance, with linear movement we just use v = dx/dt and we treat velocity v as being the same thing as dx/dt but with rotation the equation is more complicated: 
d q(t) /dt = 1/2 * W(t) q(t)

This is also discussed on the angularvelocity page 
 
What I want to do is understand the deeper reasons for this extra complexity. I think this involves these factors:

Imagine a solid object which has simultanous rotation about the x,y and z axes, the angular velocity about these axes is wx,wy and wz. This rotation could also be represented by a single rotation about the axis wx+wy+wz, this axis can be normalised to give u =( i wx2+j wy2+k wz2)/ |w(t)|. The magnitude of the rotation about this axis is |w(t)| = sqrt(wx2+wy2+wz2).

Now, in the time interval dt the angle turned will be:

|w(t)|dt

let angle turned in dt, expressed as a quaternion be:

q = (cos(|w(t)|*dt/2),u sin(|w(t)|*dt/2))

where:

The quaternion of this angle is:

q = cos(|w(t)|*dt/2) + i sin(|w(t)|*dt/2)*wx/|w(t)| + j sin(|w(t)|*dt/2)*wy/|w(t)| + k sin(|w(t)|*dt/2)*wz/|w(t)|

so since i,j and k are constants,

dq/dt = d cos(|w(t)|*dt/2)/dt + i d sin(|w(t)|*dt/2)*wx/|w(t)| / dt + j d sin(|w(t)|*dt/2)*wy/|w(t)| / dt + k d sin(|w(t)|*dt/2)*wz/|w(t)| / dt

  useful differentials:
d cos(|w(t)|*dt/2)

= -sin(|w(t)|*dt/2) (d (|w(t)|*dt/2) /dt)

= -0.5*sin(|w(t)|*dt/2) (d wx + d wy + d wz)

d sin(|w(t)|*t/2)wx/|w(t)|

= cos(|w(t)|*dt/2)*(d (|w(t)|*dt/2) /dt)*wx/|w(t)|

= 0.5*cos(|w(t)|*dt/2) wx/|w(t)| d |w(t)|

d sin(|w(t)|*t/2)wy/|w(t)|

= cos(|w(t)|*dt/2)*(d (|w(t)|*dt/2) /dt)*wy/|w(t)|

= 0.5*cos(|w(t)|*dt/2) wy/|w(t)| d |w(t)|

d sin(|w(t)|*t/2)wz/|w(t)|

= cos(|w(t)|*dt/2)*(d (|w(t)|*dt/2) /dt)*wz/|w(t)|

= 0.5*cos(|w(t)|*dt/2) wz/|w(t)| d |w(t)|

dq = -0.5*sin(|w(t)|*dt/2)(d wx + d wy + d wz)
+ i (0.5*cos(|w(t)|*dt/2) wx/|w(t)| d |w(t)|)
+ j (0.5*cos(|w(t)|*dt/2) wy/|w(t)| d |w(t)| )
+ k (0.5*cos(|w(t)|*dt/2) wz/|w(t)| d |w(t)|)

= - (wx + wy +wz)*sin(|w(t)|*dt/2)/|w(t)| + i (wx*cos(|w(t)|*dt/2) + j ( wy*cos(|w(t)|*dt/2) + k ( wz*cos(|w(t)|*dt/2))

= - wx*sin(|w(t)|*dt/2)*wx/|w(t)| -wy* sin(|w(t)|*dt/2)*wy/|w(t)| - wz*sin(|w(t)|*dt/2)*wz/|w(t)|
+ i (wx*cos(|w(t)|*dt/2) + wy*sin(|w(t)|*dt/2)*wz/|w(t)|- wz*sin(|w(t)|*dt/2)*wy/|w(t)| )
+ j ( - wx*sin(|w(t)|*dt/2)*wz/|w(t)|+ wy*cos(|w(t)|*dt/2) + wz*sin(|w(t)|*dt/2)*wx/|w(t)|)
+ k ( wx*sin(|w(t)|*dt/2)*wy/|w(t)| - wy*sin(|w(t)|*dt/2)*wx/|w(t)| + wz*cos(|w(t)|*dt/2))

= - wx*sin(|w(t)|*dt/2)*wx/|w(t)| -wy* sin(|w(t)|*dt/2)*wy/|w(t)| - wz*sin(|w(t)|*dt/2)*wz/|w(t)|
+ i (wx*cos(|w(t)|*dt/2) + wy*sin(|w(t)|*dt/2)*wz/|w(t)|- wz*sin(|w(t)|*dt/2)*wy/|w(t)| )
+ j ( - wx*sin(|w(t)|*dt/2)*wz/|w(t)|+ wy*cos(|w(t)|*dt/2) + wz*sin(|w(t)|*dt/2)*wx/|w(t)|)
+ k ( wx*sin(|w(t)|*dt/2)*wy/|w(t)| - wy*sin(|w(t)|*dt/2)*wx/|w(t)| + wz*cos(|w(t)|*dt/2))

= 0.5 (0 + i wx + j wy + k wz ) * (cos(|w(t)|*dt/2) + i sin(|w(t)|*dt/2)*wx/|w(t)| + j sin(|w(t)|*dt/2)*wy/|w(t)| + k sin(|w(t)|*dt/2)*wz/|w(t)| )

0.5*w(t)*q(t)

where:


So:

dq/dt = 0.5*w(t)*q(t)

where:

w(t) = 0 + i wx + j wy+ k wz

 

w(t) is a quaternion representing angular velocity = θ(t)*u(t) = (dq/dt) * q-1

Any angular velocity can be represented by an axis and a rotation dθ/dt about that vector (similar to axis and angle but instead axis and angle/sec). This is an instantaneous angular velocity, if there is a net torque then both dθ/dt and the axis direction may be changing, in other words they may both be functions of time.


Quaternion integration

As with differentiation we can integrate a whole quaternion by individually integrating each element. So if:

f(x) = a + b i + c j + e k

then:

∫ f(x) dx = (∫a dx) + (∫b dx) i + (∫c dx) j + (∫e dx) k


metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

 

cover us uk de jp fr ca Quaternions and Rotation Sequences.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.