Skip to content

Quaternion Calculator

Run the Quaternion Calculator MicroSim Fullscreen

You can include this MicroSim on your website using the following iframe:

<iframe src="https://dmccreary.github.io/robot-arm/sims/quaternion-calculator/main.html"
        height="522px" width="100%" scrolling="no"></iframe>

Description

Choose an axis and an angle and read the four numbers of the unit quaternion for that turn, with a picture of the half angle that the formula uses. Then calculate quaternion components, turn angles and SLERP angles in six problems. Used in Chapter 19.

A unit quaternion for a turn by an angle about an axis is q = (w, x, y, z) = (cos(angle / 2), sin(angle / 2) × axis). The formulas used in the problems are:

  • w = cos(angle / 2), and angle = 2 × arccos(w)
  • w = the square root of (1 - x² - y² - z²)
  • SLERP at fraction t from no turn to a turn of A degrees is a turn of t × A degrees
  • The angle between two rotations whose quaternions have the dot product d is 2 × arccos(d)

This MicroSim writes w first, as the chapter does. SciPy writes it last.

Lesson Plan

Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.

  1. Explore. Start with a 90 degree turn about z. Read the four numbers. Change the axis and see which number moves.
  2. Watch the half angle. Move the angle slider. The right-hand picture shows half of the angle: its cosine is w and its sine is the axis part. What is w for a turn of 180 degrees? What is it for no turn?
  3. Six problems. Choose Six problems in the menu. Work each one out, type the number and press Check. An answer must be within 0.1. Two problems ask for w × 100, so 0.866 is typed as 86.6. You get one attempt at each, and 5 of 6 is mastery.
  4. Think about it. SLERP a quarter of the way is a quarter of the angle. Why is it not a quarter of the four numbers?

Specification

The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 19: Optional Advanced Chapter: The Mathematics of Arm Paths.