PadhaikoAll subjects

3D & Composite Transformations; Viewing Transformation

Computer Graphics and Visualization (ENCT 201)

Open in the Padhaiko app

3.5 3D Transformations

Three-dimensional transformations extend 2D planar transformations into 3D space by adding a third coordinate axis () perpendicular to both the - and -axes. In 3D computer graphics, a right-handed Cartesian coordinate system is standard: when extending the right thumb along the positive -axis, fingers curl from the positive -axis toward the positive -axis.

To handle affine operations (translation, scaling, rotation, reflection, and shear) through unified linear matrix multiplication, 3D points are represented in 4D homogeneous coordinates by appending a scale parameter :

Definition

3D Affine Transformation Matrix

A 3D affine transformation is represented by a matrix :

where the upper-left submatrix controls linear transformations (rotation, scaling, reflection, and shear), and the rightmost column specifies translation.

Elementary 3D Transformations

1. 3D Translation

Translation displaces an object position along the three coordinate axes by offsets :

The homogeneous translation matrix is:

The inverse translation is .

2. 3D Scaling

Scaling modifies object dimensions relative to the coordinate origin along the directions by factors :

The homogeneous scaling matrix is:

3. 3D Rotations About Coordinate Axes

In 3D space, an axis of rotation must be specified. In a right-handed system, a positive rotation angle is defined as counterclockwise when looking down the positive rotation axis toward the coordinate origin.

Theorem

Coordinate Axis Rotation Matrices

  1. Rotation About the -Axis (): The -coordinate remains unchanged, while and rotate identically to 2D planar rotation:
  1. Rotation About the -Axis (): The -coordinate remains unchanged; cyclic permutation of axes () gives rotation in the -plane:
  1. Rotation About the -Axis (): The -coordinate remains unchanged. Following cyclic order , looking down toward the origin rotates toward :

4. 3D Reflection

Reflection produces a mirror image of an object across a specified reflection plane:

5. 3D Shear

Shearing deforms an object along coordinate planes. For instance, shearing parallel to the -plane controlled by parameters and shifts coordinates as :

3.6 3D Composite Transformations and Arbitrary-Axis Rotation

Complex spatial transformations are formed by concatenating elementary matrices through matrix multiplication. For column vectors, transformations are applied in sequence from right to left:

Because 3D matrix multiplication is non-commutative (), the exact sequence of transformations is critical.

3D Rotation About an Arbitrary Axis in Space

A fundamental operation in 3D graphics and robotics is rotating an object by an angle about an arbitrary line in space.

Let the rotation axis pass through an arbitrary point with direction vector . The normalized unit vector along the axis is:

To execute the rotation using standard coordinate axis matrices, the arbitrary axis must be aligned with one of the coordinate axes (typically the positive -axis), rotated by , and returned to its original position.

Theorem

Arbitrary Axis 3D Rotation Sequence

The composite transformation matrix for rotating by angle about an arbitrary axis passing through with unit direction is computed through seven sequential operations:

where:

If the direction vector is already parallel to the -axis (), the rotations about and are omitted, and rotation is performed directly about .

3.7 Projection and Viewing Transformation

In 3D computer graphics, rendering an image requires passing geometric primitives through a sequence of coordinate transformations known as the 3D Viewing Pipeline.

The 3D Viewing Pipeline

The 3D graphics pipeline processes coordinates through five standardized spaces:

  1. Modeling Coordinates (MC): Local coordinate system in which individual 3D objects (e.g. teapot, vehicle, character) are originally constructed.
  2. World Coordinates (WC): A unified global coordinate frame in which all objects, light sources, and cameras are positioned via Modeling Transformations.
  3. Viewing Coordinates (VC / Camera Space): A coordinate frame centered at the virtual camera's optical center with its axes aligned with the camera's viewing direction, achieved via the Viewing Transformation.
  4. Normalized Device Coordinates (NDC): A device-independent normalized cube (canonical view volume ) obtained by applying the Projection Transformation and perspective division. Primitives outside this volume are clipped.
  5. Device Coordinates (DC / Screen Space): 2D integer pixel coordinates on the display raster (or viewport window) generated by the Viewport Transformation.

World-to-Viewing Coordinate Transformation

The transformation from World Coordinates to Viewing Coordinates aligns the camera coordinate system with the world coordinate axes. The virtual camera is specified by three parameters in world space:

  1. View Reference Point (Eye Position): , the camera's location in world space.
  2. Look-At Point (Reference Target): , the point the camera is looking toward.
  3. View-Up Vector: , a vector indicating the upward orientation of the camera (does not need to be strictly orthogonal to the line of sight).

Constructing the Orthonormal Camera Basis

From these parameters, an orthonormal right-handed basis is constructed:

  1. View Plane Normal (): Vector along the camera's optical axis pointing backwards (from toward , matching the positive -axis in a right-handed system):
  1. Horizontal Camera Vector (): Perpendicular to both the view-up vector and the viewing direction, pointing to the camera's right (along positive ):
  1. Orthogonal Up Vector (): Perpendicular to both and , pointing along the camera's true upward direction (positive ):
Theorem

World-to-Viewing Coordinate Transformation Matrix

Mapping world coordinates to viewing coordinates requires two operations:

  1. Translating the camera position to the world origin: .
  2. Rotating the camera basis vectors to align with the world coordinate axes : .

The composite world-to-viewing transformation matrix is:

Multiplying the two matrices yields the closed-form viewing transformation matrix:

Worked Examples

Example

Composite 3D Transformation: Scaling About a Fixed Point Followed by Rotation (5 marks)

A 3D point undergoes the following sequential transformations:

  1. Uniform scaling by a factor of with respect to fixed point .
  2. Rotation by counterclockwise about the -axis.

Calculate the final coordinates of point .

Decomposing Fixed-Point Scaling: Scaling about a fixed point requires:

Translating to the local origin relative to :

Applying Uniform Scaling and Inverse Translation: Scaling by factor :

Translating back to :

Applying Rotation About the -Axis: The rotation matrix for about the -axis () is:

Multiplying with point :

Answer:

The final coordinates after fixed-point scaling and rotation are .

Example

3D Rotation About an Arbitrary Line Parallel to a Coordinate Axis (5 marks)

A 3D object vertex is located at . Rotate this vertex by an angle of counterclockwise about the line passing through point and parallel to the -axis.

Decomposition of the Rotation Sequence: The rotation axis passes through with direction parallel to the -axis (). Because the line is parallel to the -axis, no angular alignment rotations ( or ) are required. The composite transformation sequence is:

  1. Translate the line to the -axis: .
  2. Rotate by about the -axis: .
  3. Translate back to original position: .

Evaluating Coordinates at Each Stage:

  1. Translating vertex by :
  1. Rotating by about the -axis ():
  1. Translating back by :
Answer:

The rotated coordinates are .

Example

Camera Coordinate Basis Construction and World-to-Viewing Transformation (5 marks)

A virtual camera in a 3D graphics system is defined in world coordinates by:

  1. Determine the orthonormal camera basis vectors .
  2. Formulate the world-to-viewing transformation matrix .
  3. Transform the world coordinate point into viewing coordinates.

Constructing Camera Basis Vectors:

  1. View Normal Vector ():
  1. Horizontal Camera Vector ():
  1. Orthogonal Up Vector ():

Assembling the Viewing Transformation Matrix: Computing translation dot products:

The viewing matrix is:

Transforming World Point : Applying the matrix to :

The viewing coordinates are . (Notice , which is consistent with the camera looking along the axis into the scene).

Answer:
  1. Camera basis vectors: .
  2. Viewing transformation matrix:
  1. Viewing coordinates: .

Exercises

3D Transformations and Viewing Exercises

Question 1

Derive the rotation matrix for counterclockwise rotation by angle about the -axis in a right-handed Cartesian coordinate system. Explain why the sign pattern of the sine terms differs from that of the - and -axis rotations.

Cyclic Permutation of Coordinate Axes: In a right-handed 3D coordinate system, cyclic permutation of axes follows the cycle . For rotation about the -axis, the primary axis is and secondary is . For rotation about the -axis, the primary axis is and secondary is . For rotation about the -axis, the primary axis is and secondary is .

Deriving Transformation Equations: Holding fixed (), rotating from toward by angle gives:

Expressing in standard column vector order:

Matrix Assembly and Sign Pattern Analysis: In homogeneous matrix form:

In and , the negative sine term appears in the upper row ( at row 0 col 1 in , and at row 1 col 2 in ). In , because precedes in the cyclic order, the row corresponding to (row 0) contains , while the row corresponding to (row 2) contains .

Answer:

The rotation matrix about the -axis is:

The reversed sign pattern arises from preserving cyclic axis permutation () to ensure a right-handed rotation.

Question 2

A 3D object vertex is located at . Apply a counterclockwise rotation about the -axis, followed by a translation of vector . Determine the final coordinates of the vertex.

Rotation About the -Axis by : For : . The rotation matrix is:

Multiplying with point :

Thus, .

Applying Translation : Adding translation components:

Thus, .

Answer:

The final coordinates of the transformed vertex are:

Question 3

Detail the step-by-step 7-phase sequence of transformations required to rotate a 3D object by an angle about an arbitrary line in space passing through point with direction vector where .

Objective and Conceptual Decomposition: To execute rotation about an arbitrary line, standard coordinate axis rotations () are utilized. The arbitrary line must be aligned with the coordinate origin and one of the principal axes (commonly chosen as the positive -axis), rotated by , and then mapped back to its original location via inverse transformations.

The 7 Sequential Operations:

  1. Translate line to origin: Apply translation so that point coincides with the coordinate origin.
  2. Rotate about -axis into -plane: Rotate by angle about the -axis to bring the direction vector into the -plane. With projected length , and .
  3. Rotate about -axis onto -axis: Rotate by angle about the -axis so that the direction vector aligns with the positive -axis. Here and .
  4. Perform required rotation: Rotate the object by the specified angle about the -axis using .
  5. Inverse rotation about -axis: Apply to restore the vector from the -axis back to the -plane.
  6. Inverse rotation about -axis: Apply to restore the vector to its original 3D orientation.
  7. Inverse translation: Apply to move the line back to point .

Composite Transformation Matrix: Multiplying the transformation matrices from right to left:

Answer:

The 7-step sequence is:

where (), and .

Question 4

Rotate the point by about the line passing through the origin along the direction vector (the -axis).

Formulating Rotation About the -Axis: The line passes through the origin () and is aligned with the positive -axis (). Thus, no translations or axis-alignment rotations are needed. The transformation is simply an -axis rotation .

Applying Matrix Transformation: For : . The rotation matrix is:

Multiplying with point :

Answer:

The rotated coordinates are .

Question 5

Explain the five fundamental coordinate spaces and transformation stages comprising the 3D graphics viewing pipeline, from Model Coordinates to Device Coordinates.

The Five Coordinate Spaces:

  1. Model Coordinates (MC): Local coordinates used to define the geometry of individual objects in isolation.
  2. World Coordinates (WC): A common, shared coordinate frame in which multiple models, lights, and cameras are positioned.
  3. Viewing Coordinates (VC): Coordinates relative to the camera, with the origin at the camera eye and the -axis aligned with the viewing direction.
  4. Normalized Device Coordinates (NDC): Device-independent canonical space (typically ) obtained after projection and perspective division, where primitive clipping takes place.
  5. Device Coordinates (DC): Integer 2D screen coordinates representing physical pixels on the output display device.

The Transformation Stages:

  • Modeling Transformation (): Scales, rotates, and translates local models into their global world positions ().
  • Viewing Transformation (): Translates and rotates the world scene into camera-centric coordinates ().
  • Projection Transformation (): Converts the viewing frustum into the canonical box via parallel or perspective projection and perspective division ().
  • Viewport Transformation (): Scales and translates normalized coordinates to fit the pixel dimensions of the display window ().
Answer:

The 3D viewing pipeline consists of:

It bridges local model authoring to raster screen pixels through sequential affine and projective transformations.

Question 6

A virtual camera is located at looking toward the origin with view-up vector .

  1. Construct the camera unit basis vectors .
  2. Calculate the viewing coordinates for the world point .

Constructing Camera Unit Basis :

  1. View Normal Vector ():
  1. Horizontal Camera Vector ():
  1. Orthogonal Up Vector ():

Transforming World Point : The relative displacement vector from the camera eye is:

Projecting onto camera basis vectors:

Answer:
  1. Camera basis vectors:
  2. Viewing coordinates: .

Past exam questions for Computer Graphics and Visualization

← Parallel & Perspective ProjectionParametric Cubic Curves, Splines, Bezier & Polygon Surfaces →