2.1 Coordinate Systems

As is typical in computer graphics, pbrt represents three-dimensional points, vectors, and normal vectors with three coordinate values: x , y , and z . These values are meaningless without a coordinate system that defines the origin of the space and gives three linearly independent vectors that define the x y , and  z axes of the space. Together, the origin and three vectors are called the frame that defines the coordinate system. Given an arbitrary point or direction in 3D, its left-parenthesis x comma y comma z right-parenthesis coordinate values depend on its relationship to the frame. Figure 2.1 shows an example that illustrates this idea in 2D.

Figure 2.1: In 2D, the left-parenthesis x comma y right-parenthesis coordinates of a point normal p Subscript are defined by the relationship of the point to a particular 2D coordinate system. Here, two coordinate systems are shown; the point might have coordinates left-parenthesis 8 comma 8 right-parenthesis with respect to the coordinate system with its coordinate axes drawn in solid lines but have coordinates left-parenthesis 2 comma negative 4 right-parenthesis with respect to the coordinate system with dashed axes. In either case, the 2D point normal p Subscript is at the same absolute position in space.

In the general n -dimensional case, a frame’s origin normal p Subscript normal o and its n linearly independent basis vectors define an n -dimensional affine space. All vectors bold v in the space can be expressed as a linear combination of the basis vectors. Given a vector bold v and the basis vectors bold v Subscript i , there is a unique set of scalar values s Subscript i such that

bold v equals s 1 bold v 1 plus midline-horizontal-ellipsis plus s Subscript n Baseline bold v Subscript n Baseline period

The scalars s Subscript i are the representation of bold v with respect to the basis StartSet bold v 1 comma bold v 2 comma ellipsis comma bold v Subscript n Baseline EndSet and are the coordinate values that we store with the vector. Similarly, for all points normal p Subscript , there are unique scalars s Subscript i such that the point can be expressed in terms of the origin normal p Subscript normal o and the basis vectors

normal p Subscript Baseline equals normal p Subscript normal o Baseline plus s 1 bold v 1 plus midline-horizontal-ellipsis plus s Subscript n Baseline bold v Subscript n Baseline period

Thus, although points and vectors are both represented by x , y , and z coordinates in 3D, they are distinct mathematical entities and are not freely interchangeable.

This definition of points and vectors in terms of coordinate systems reveals a paradox: to define a frame we need a point and a set of vectors, but we can only meaningfully talk about points and vectors with respect to a particular frame. Therefore, in three dimensions we need a standard frame with origin left-parenthesis 0 comma 0 comma 0 right-parenthesis and basis vectors left-parenthesis 1 comma 0 comma 0 right-parenthesis , left-parenthesis 0 comma 1 comma 0 right-parenthesis , and left-parenthesis 0 comma 0 comma 1 right-parenthesis . All other frames will be defined with respect to this canonical coordinate system, which we call world space.

2.1.1 Coordinate System Handedness

There are two different ways that the three coordinate axes can be arranged, as shown in Figure 2.2. Given perpendicular x and y coordinate axes, the z axis can point in one of two directions. These two choices are called left-handed and right-handed. The choice between the two is arbitrary but has a number of implications for how some of the geometric operations throughout the system are implemented. pbrt uses a left-handed coordinate system.

Figure 2.2: (left) In a left-handed coordinate system, the z axis points into the page when the x and y axes are oriented with x pointing to the right and y pointing up. (right) In a right-handed system, the  z axis points out of the page.