logo back up home forward   further reading more topics »

Maths - Dual Quaternion Example

Amy de Buitléir has kindly sent me this nice step-by-step example.

It illustrates how it is easier to just work with dual quaternions and forget about vectors..

Ex: We have a prop inside a container, which is inside a scene.
The prop is at (0, 0, 100), specified in the container's co-ordinate system.
The container is at (0, 0, 0), specified in the scene's co-ordinate system.
The container is also rotated +30° around the y-axis.

dual quaternion example

Note: I have shown the coordinates differently from usual (z down, y toward viewer).

Q: What is the location of the prop, specified in the scene's co-ordinate
system?

First, we need to build a dual quaternion to represent the state (location and rotation) of the prop wrt (with respect to) the container. We'll call this dual quaternion Q(prop,container).

The position of the prop with respect to the container can be represented by
the quaternion:

         t(prop,container) = (0, 0, 0, 100)

The real part of the dual quaternion Q(prop,container) is 1 because prop isn't rotated. The dual part is:

    dual part = (1/2)(real)t = (1/2)(1)(0, 0, 0, 100) = (0, 0, 0, 50)

    Q(prop,container) = 1 + ε(0, 0, 0, 50)

Next, we need to build a dual quaternion to represent the state of the container wrt the scene.

    t(container,home) = 0 because the container is not translated.

    The container is rotated 30 around the y-axis, so
    sx2 = sz2 = 0    sy2 = sin(30/2) = 0.2588
    cx2 = cz2 = 1    cy2 = cos(30/2) = 0.9659
    real part = (0.9659, 0, 0.2588, 0)

    dual part = (1/2)(real)t = 0

    Q(container,home) = (0.9659, 0, 0.2588, 0) + ε0 = (0.9659, 0, 0.2588, 0)

Now we're ready to calculate the state of the prop wrt the scene:

         Q(prop,home) = Q(prop,container) * Q(container,home)
         = [1 + ε(0, 0, 0, 50)] (0.9659, 0, 0.2588, 0)
         = (0.9659, 0, 0.2588, 0) + ε(0, 0, 0, 50)(0.9659, 0, 0.2588, 0)
         = (0.9659, 0, 0.2588, 0) + ε(0, -12.94, 0, 48.295)

We can easily extract the translation from this dual quaternion.
        
         t(prop,home) = 2*real†*dual
         = 2(0.9659, 0, 0.2588, 0)†(0, -12.94, 0, 48.295)
         = 2(0.9659, 0, -0.2588, 0)(0, -12.94, 0, 48.295)
         = 2(0, -25.0, 0, 43.3)
         = (0, -50, 0, 86.6)

We can double-check this using an inverse transformation. We'll use the last
quaternion to calculate the state of the prop wrt the container, and verify
that it agrees with the original quaternion.

         Q(prop,container) = Q(prop,home) * Q(home,container)
         = Q(prop,home) * Q(container,home)†
         = [(0.9659, 0, 0.2588, 0) + ε(0, -12.94, 0, 48.295)] (0.9659, 0, 0.2588, 0)†
         = [(0.9659, 0, 0.2588, 0) + ε(0, -12.94, 0, 48.295)] (0.9659, 0, -0.2588, 0)
         = 1 + ε(0, -12.94, 0, 48.295)(0.9659, 0, -0.2588, 0)
         = 1 + ε(0, 0, 0, 50)

Which agrees with the original calculation.


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.

cover us uk de SuSE Linux 11.0. Operating system with a wide range of applications including Open Office. A good distribution for developers as it contains KDevelop. Java, Mono, etc. Can install itself as a dual-boot system with an existing Windows OS if required. For information about installing it see this page.

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

Terminology and Notation

Specific to this page here:

 

program

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

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

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