3D Concepts and Transformations
Three-dimensional graphics extends the ideas of 2D graphics to a world of depth. Objects are described by 3D coordinates, scenes are viewed from arbitrary vantage points, and images are projected onto a 2D display. This chapter introduces the representation of 3D objects, the extensions of transformations to three dimensions, and the projection methods that convert 3D scenes to 2D images.
Representation of 3D Objects
Several representations are used for 3D objects. Polygonal meshes, typically triangle meshes, are the most common because GPUs are highly optimized for triangle rasterization. Each vertex stores its 3D position and optional attributes such as colour, normal vector, and texture coordinates. Parametric surfaces, including Bézier patches and NURBS, are used in CAD because they provide exact representations of curves and surfaces with a few control points. Implicit surfaces, defined by equations such as f(x, y, z) = 0, and voxel grids find use in medical imaging and volumetric rendering.
3D Coordinate Systems
A 3D coordinate system assigns a triple (x, y, z) to every point in space. Graphics systems may use a right-handed system, where the cross product of the x and y axes points in the positive z direction, or a left-handed system, common in Direct3D. Conversions between the two are simple but important to keep track of, particularly when exchanging models between programs.
3D Translation, Rotation, and Scaling
Translation in 3D adds (tx, ty, tz) to each coordinate. Scaling multiplies each coordinate by its own scale factor. Rotation in 3D is more complex because it can occur about any axis. Rotations about the x, y, and z axes each have simple 3×3 matrix forms; rotations about an arbitrary axis are composed as a sequence of axis-aligned rotations or expressed directly using Rodrigues' rotation formula.
Homogeneous Coordinates in 3D
Just as in 2D, homogeneous coordinates unify translation with rotation and scaling. A 3D point is represented as (x, y, z, 1), and transformations are represented as 4×4 matrices. Perspective projection requires the full power of homogeneous coordinates, since it produces points with the fourth coordinate different from 1 that must be normalized.
Composite 3D Transformations
Complex motions in 3D are composed by multiplying 4×4 matrices. Hierarchical modelling, where objects are arranged in a scene graph, uses composite transformations to express the position of each child relative to its parent. A robot arm, for example, may have transformations for the base, shoulder, elbow, and wrist multiplied in sequence so that moving the shoulder automatically moves all downstream parts.
Euler Angles and Quaternions
Rotations in 3D can be parameterized by Euler angles—rotations about three axes in a fixed order—but these suffer from gimbal lock, a degenerate configuration where one rotational degree of freedom is lost. Quaternions provide a more robust representation. A unit quaternion q = (w, x, y, z) represents a rotation by 2arccos(w) about the axis (x, y, z). Quaternion multiplication corresponds to composition of rotations without singularities.
Projections
Mapping a 3D scene to a 2D image requires a projection. Parallel projections preserve relative dimensions and parallelism. Orthographic projection simply drops the z-coordinate. Oblique projections tilt the view. Perspective projections simulate the way real cameras work: objects farther from the viewer appear smaller. The perspective matrix divides each coordinate by its distance from the viewer, a process known as the perspective divide.
Viewing Pipeline
The 3D viewing pipeline is: modelling transformation, placing an object in world coordinates; viewing transformation, moving the world so the camera is at the origin looking down −z; projection to normalized device coordinates; clipping against the canonical view volume; and finally viewport transformation to pixel coordinates. Every 3D renderer implements some version of this pipeline.
Summary
Three-dimensional graphics introduces depth, new coordinate systems, and more complex rotations. Using 4×4 homogeneous matrices we can express all linear and projective transformations uniformly. The viewing pipeline transforms 3D models through model, view, projection, and viewport stages, producing the final 2D image. Subsequent chapters address the additional challenges of hiding surfaces, representing curves, and simulating realistic lighting.