A key component of the DIRSIG model’s geometry support is the positioning and orienting various objects in 3D space. This concept includes the positioning of scene objects (see the ODB and GLIST files) as well as the platform (see the PPD file). The primary mechanism employed to perform this task is the affine transform, which is a combination of rotations, translations, scales (dilations) and shears. An affine transform has two very specific properties:

  • Collinearity is preserved

    • All points lying on a line still lie on a line after the transformation is applied.

  • Ratios of distances are preserved

    • The midpoint of a line segment remains the midpoint after the transformation is applied.

Note Historically the DIRSIG model hasn’t employed shear operations, although they are completely supported via any interfaces that allow the user to input the raw 4x4 affine transform.

Common Transforms

The following section outlines the mathematics defining common operations applied to objects in the DIRSIG model. These operations will be defined in terms of how they operate on a 3D point, however the concept can be applied to entire 3D lines (defined by 2 or more points), 3D polygons (defined by 3 or more non-collinear points) or a 3D object (defined by 1 or more 3D polygons). However, most of this document will discuss a given transform M in terms of an operation on a point p, yielding the new point p':

affine__1.png

Since the DIRSIG model addresses a 3D world, the operations will be defined in terms of the Euclidean X, Y and Z axes.

Translation

A translation operation will translate a point from an initial position to a new position based on a linear shift. For example, a point that is distance N from the origin can be translated a distance M such that the final distance is N+M.

images/affine/translate.png
Figure 1. An X-axis translation operation on two points.

The following equations define the 4x4 matrix for translation in the various axes.

affine__2.png
Figure 2. The X-axis translation matrix
affine__3.png
Figure 3. The Y-axis translation matrix
affine__4.png
Figure 4. The Z-axis translation matrix

A series of axis translation operations are commutative, hence the total translation for each axis in the series can be summed (translations are additive) and a single transform matrix capturing translations for all axes can be computed directly:

affine__5.png
Figure 5. The combined translation matrix

Scale

A scale operation will shift a point from an initial position to a new position based on a scaling. For example, a point that is currently a distance N from the origin can be scaled by 2 to increase that distance to 2N.

images/affine/scale.png
Figure 6. An X-axis scaling operation on two points.

The following equations define the 4x4 matrix for scaling in the various axes.

affine__6.png
Figure 7. The X-axis scaling matrix
affine__7.png
Figure 8. The Y-axis scaling matrix
affine__8.png
Figure 9. The Z-axis scaling matrix

A series of axis scale operations are commutative, hence the total scaling for each axis in the series can be combined (scales are multiplicative) and a single transform matrix capturing scalings for all axes can be computed directly:

affine__9.png
Figure 10. The total scaling matrix

Rotation

A rotation operation will shift a point from an initial position to a new position based on a rotation about a given axis. For example a point that currently has an angle of theta between a line drawn from the point back to the origin and a reference axis can be rotated about an axis normal to the plane so that the new position forms a new angle to that reference axis.

images/affine/rotate.png
Figure 11. A positive Z-axis rotation operation on a single point (the +Z axis is out of the page).

The following equations define the 4x4 matrix for rotation in the various axes. Note that the signs of rotation angles are defined using a right-hand rule convention.

affine__10.png
Figure 12. The X-axis rotation matrix
affine__11.png
Figure 13. The Y-axis rotation matrix
affine__12.png
Figure 14. The Z-axis rotation matrix

Unlike the translation and scaling operations, a series of axis rotations are not commutative. That means that rotating a point about the X axis and then the Y axis yields a different result than if you rotate about the Y axis and then the X axis.

affine__13.png
Note The order "X, then Y" must be translated into a matrix math form, where the matrix multiplication operations are performed right to left. Hence, "X, then Y" results in an equation that looks like p' = My * ( Mx * p ).

Transform Sequences

This section explains how an arbitrary sequence of translation, scale and/or rotation operations can be combined. The key concept is that the result of the previous operation is the input to the next operation. Consider the following sequence of operations that start with a point at the origin:

  • The point p0 is translated from the origin in the X dimension to the point p1.

  • The point p1 is translated in the Y dimension to the point p2.

  • The point p2 is rotated about the Z axis to the point p3.

images/affine/composed_point1.png
Figure 15. A sequence of X translation, then Y translation and then Z rotation operations on a point.

This sequence of operations can be combined into a single affine transform matrix by combining the transform matrices in the correct mathematical order:

affine__14.png
Figure 16. The affine transform resulting from a X translation, then a Y translation and then a Z rotation sequence.

Sequence Equality

By looking at the final state of the operation sequence (p3) described in the previous section, the reader can see that the p0 to p3 transform could be accomplished by a simpler set of operations:

  • The point p0 is translated from the origin in the X dimension to the point p1.

  • The point p1 is translated in the Y dimension to the point p2.

images/affine/composed_point2.png
Figure 17. A sequence of X translation and then Y translation operations on a point.

Although this results in the final point being in the same location, the sequences are only equivalent when applied to a single point. Consider the same pair of sequences again for square object, where the transforms modify the points defining the corners of the square:

images/affine/composed_box1.png
Figure 18. A sequence of X translation, then Y translation and then Z rotation operations on a square.

Now consider the simplified transform consisting of only X and Y translations:

images/affine/composed_box2.png
Figure 19. A sequence of X translation and then Y translation operations on a square.

Notice how the final location of the square is the same between the two sequences but orientation is not. This is an important property to consider when affine transforms are utilized with collections of points like those in lines, polygons and collections of polygons.

Important In general, a complex set of operations results in a final state that is unique to that set of operations and the order that they were applied in.

Interpolation

It is very common to want to interpolate between a set of states described by affine transforms. For example, a car driving down a road might be described by a series of states at different waypoints. Each state would include the location (a set of translation operations) and an orientation (a set of rotation operations). To determine the location and orientation of the car between the waypoints, the location and orientation must be interpolated from the neighboring known states. Although an 4x4 affine transform composed of just translation and/or scale operations can be linearly interpolated by weighting the elements in the 4x4 matrix, a transform containing rotations cannot. Instead the axis translations, scales and rotations must be interpolated and the affine transform matrix generated from the resulting values. It is important to note that this approach is only valid if the order of the rotation operations between the two know waypoints are the same.

Tip One of the advantages to using quaternions is that there is a scheme for interpolating an arbitrary sequence of rotations directly. Support for quaternions will be added in future versions of DIRSIG.

Affine Transforms in Use

This section briefly discusses how affine transforms are used in different parts of DIRSIG.

Object Instances

An instance description in an ODB or GLIST file is an affine transform. This is a case of a fixed sequence of scale, rotation and translation operations (there is a single operation for each axis). The order of the operations for an instance description is:

  • The object is scaled

  • Then the object is rotated

    • The axis rotation order in an ODB file is always Z, then Y and then X.

    • The default axis rotation order in an GLIST file is Z, then Y and then X, but the user can change the order if desired.

  • Finally, the object is translated

Platform Attachments

A mount attachment (to the respective platform) and an instrument attachment (to the respective mount) is an affine transform. This is an arbitrary sequence of translation and rotation operations, although scale operations are not usually employed (they do not make sense in the physical metaphor of the platform).

Platform Orientation

The PPD file describes the platform orientation as a sequence of X, Y and Z rotations. The user can specify the order of the rotations, but there is a single rotation for each axis.