Quaternion Classes (Advanced Methods in Computer Graphics)

This section gives an outline of methods in the classes that represent quaternion and dual quaternion numbers. Figure D.1 shows the static relationships between the classes and the geometry classes.

Relationships between the quaternion classes and the geometry classes

Fig. D.1 Relationships between the quaternion classes and the geometry classes

Quaternion Class

tmpf9b3-289

Description:

Every quaternion object has an associated 4 x 4 transformation matrix _mat. The matrix elements are not automatically updated. The user needs to call updateMatrix to compute the values of the matrix elements. The constants RADTODEG and DEGTORAD store the conversion factors from radians to degrees and degrees to radians respectively. The quaternion components _q0, _q1, _q2, _q3 are declared as public as they are frequently accessed. EPS stores the constant value 1.E-6 used as a threshold for checking if a value is close to zero.


tmpf9b3-290

Description:

The first constructor initializes an object with four quaternion components. The second constructor takes a point P = (x, y, z) as the argument, and forms the pure quaternion (0, x, y, z). The third constructor forms a unit quaternion using the angle and axis of a threedimensional rotation as parameters. The quaternion is constructed as per Eq. 5.44. The fourth no-argument constructor initializes the quaternion components to (1, 0, 0, 0).

tmpf9b3-291

Description:

The first getter method given above returns the current matrix _mat. The second getter method returns the last three components _q1, _q2, _q3 of the current quaternion as a point. The third and fourth getter methods return respectively the angle and axis of the equivalent rotation given by Eqs. 5.45 and 5.46. The method getEuler extracts the Euler angles from the quaternion components using Eq. 5.56.

tmpf9b3-292

Description:

The methods listed above perform algebraic operations of addition, subtraction, multiplication, scalar multiplication, conjugation and negation, and return the resulting quaternion.

tmpf9b3-293

Description:

The above method returns the magnitude of the current quaternion (Eq. 5.17).

tmpf9b3-294

Description:

Each quaternion object has an associated transformation matrix as given in Eq. 5.23. The above method must be called whenever a quaternion component has changed, in order to update this matrix.

tmpf9b3-295

Description:

The above method transforms a point using the current quaternion according to the formula P’ = QPQ*.

tmpf9b3-296

Description:

The method normalize converts the current quaternion to a unit quaternion.

tmpf9b3-297

Description:

The above methods perform linear (lerp) and spherical linear (slerp) interpolations between the current quaternion and the supplied quaternion q, and return an intermediate quaternion for the parameter value given by t.

tmpf9b3-298

Description:

The above method prints the component values of the current quaternion.

Dual Quaternion Class

tmpf9b3-299

Description:

Each dual quaternion is composed using two quaternions _quat1, _quat2 as described in Sect. 5.9.2.

tmpf9b3-300

Description:

The first constructor shown above forms a dual quaternion using two quaternion components. The second constructor using the rigid-body transformation parameters (angle and axis of rotation, and translation vector) to construct the equivalent dual quaternion. The third constructor creates the dual quaternion (1, 0, 0, 0, 0, x, y, z) using the coordinates (x, y, z) of the specified point.

tmpf9b3-301

Description:

The first two methods shown above return respectively the first and the second quaternion components of the current dual quaternion. The third method returns the last three elements (of the second quaternion component) as the coordinates of a point.

tmpf9b3-302

Description:

The above method returns the product of the current dual quaternion and the specified dual quaternion (q). The product is computed using the formula in Eq. 5.85.

tmpf9b3-303

Description:

The above method returns the product of the current dual quaternion and the specified quaternion (q). The product is computed using the formula in Eq. 5.86.

tmpf9b3-304

Description:

The above method transforms a point using the current quaternion according to the formula in Eq. 5.97.

tmpf9b3-305

Description:

The above method prints the component values of the current dual quaternion.

Next post:

Previous post: