Different coordinate spaces are needed because some information is only meaningful in a particu- lar context.
3.2.1 World Space
One of the authors of this book wrote in Lewisville, Texas (near Dallas and Fort Worth). More pre- cisely, his location is:
n Latitude: 33° 01’ North
n Longitude: 96° 59’ West The other author wrote in Denton, Texas, at:
n Latitude: 33° 11’ North
n Longitude: 97° 07’ West
These values express our “absolute” position in the world. You don’t need to know where Denton, Lewisville, Texas, or even the United States is to use this information because the position is abso- lute. (The astute reader will note that these coordinates are not Cartesian coordinates, but rather, they are polar coordinates. That is not significant for this discussion — we live in a flat 2D world wrapped around a sphere, a concept that supposedly eluded most people until Christopher Colum- bus verified it experimentally.) The origin, or (0,0) point in the world, was decided for historical reasons to be located on the equator at the same longitude as the Royal Observatory in the town of Greenwich, England.
The world coordinate system is a special coordinate system that establishes the “global” refer- ence frame for all other coordinate systems to be specified. In other words, we can express the position of other coordinate spaces in terms of the world coordinate space, but we cannot express the world coordinate space in terms of any larger, outer coordinate space.
In a non-technical sense, the world coordinate system establishes the “largest” coordinate sys- tem that we care about, so the world coordinate system need not actually be the whole world. For
example, if we wanted to render a view of Cartesia, for all practical purposes Cartesia would be “the world,” since we wouldn’t care where Cartesia is located (or even if it exists at all). In differ- ent situations, your world coordinate space will define a different “world.” In Section 4.3.1 we will discuss how “absolute position” is technically undefined. In this book, we will use the term “absolute” to mean “absolute with respect to the largest coordinate space we care about.” In other words, “absolute” to us will mean “expressed in the world coordinate space.”
The world coordinate space is also known for obvious reasons as the global or universal coor- dinate space.
Some examples of questions that are typically asked in world space include questions about initial conditions and the environment, such as:
n What is the position and orientation of each object?
n What is the position and orientation of the camera?
n What is the terrain like in each position in the world? (For example, hills, mountains, build- ings, lakes.)
n How does each object get from where it is to where it wants to be? (Motion planning for nonplayer characters.)
3.2.2 Object Space
Object space is the coordinate space associated with a particular object. Every object has its own independent object space. When an object moves or changes orientation, the object coordinate space associated with that object is carried along with it, so it moves or changes orientation too. For example, we all carry our own personal coordinate system around with us. If we were to ask you to “take one step forward,” we are giving you an instruction in your object space. (Please for- give us for referring to you as an object.) We have no idea which way you will move in absolute terms. Some of you will move north, some south, and others in different directions. Concepts such as “forward,” “back,” “left,” and “right” are meaningful in object coordinate space. When some- one gives you driving directions, sometimes you are told to “turn left” and other times you are told to “go east.” “Turn left” is a concept that is expressed in object space, and “east” is expressed in world space.
Locations can be specified in object space as well as directions. For example, if I asked you where the muffler on your car was located, you wouldn’t tell me “in Chicago,” even if you lived in Chicago. I’m asking where it is within your car. In other words, I want you to express the location of your muffler in the object space of your car.
In certain contexts, object space is also known as modeling space, since the coordinates for the vertices of a model are expressed in modeling space. It is also known as body space.
Some examples of questions that can be asked in object space are:
n Is there another object near me that I need to interact with? (Do I need to kill it?)
n In what direction is it? Is it in front of me? Slightly to my left? To my right? (So I can shoot at it or run in the opposite direction.)
3.2.3 Camera Space
Camera space is the coordinate space associated with an observer. Camera space is similar to screen space except that camera space is a 3D space, whereas screen space is a 2D space. Camera space can be considered a special object space, where the “object” that defines the coordinate space is the camera defining the viewpoint for the scene. In camera space, the camera is at the ori- gin with +x pointing to the right, +z pointing forward (into the screen, or the direction the camera is facing), and +y pointing “up” (not “up” with respect to the world, but “up” with respect to the top of the camera). Figure 3.1 shows a diagram of camera space.
Note that other books may use different conventions for the orientation of the axes in camera space. In particular, many graphics books that use a right-handed coordinate system point –z into the screen, with +z coming out of the screen toward the viewer.
Typical questions asked in camera space include queries about what is to be drawn on the screen (graphics questions), such as:
n Is a given point in 3D space in front of the camera?
n Is a given point in 3D space on screen, or is it off to the left, right, top, or bottom edges of the camera frustum? (The frustum is the pyramid of space that can be seen by the camera.)
n Is an object completely on screen, partially on screen, or completely off screen?
n Which of the two objects is in front of the other? (This is called occlusion information.) Notice that the answers to these questions are critical if we wish to render anything. In Section 15.3 we will learn how 3D camera space is related to 2D screen space through a process known as
projection.
Chapter 3: Multiple Coordinate Spaces
27
3.2.4 Inertial Space
Sometimes the right terminology is the key to unlocking a better understanding of a subject. In an attempt to simplify the transformations between world and object space, we will use a new coordi- nate space called the inertial coordinate space, which is in a certain sense “halfway” between object space and world space. The origin of inertial space is the same as the origin of the object space, and the axes of inertial space are parallel with the axes of world space. Figure 3.2 illustrates this principle in 2D. (Notice that we have chosen to consider the point between the robot’s feet as the origin of the robot’s object space, rather than the robot’s center of mass.)
Why is inertial space interesting? To transform a point between object space and inertial space requires only rotation, and to transform a point between inertial space and world space requires only a change of location, or a translation. Thinking about these two things independently is eas- ier than trying to cope with both of them. This is shown in Figures 3.3 to 3.5. Figure 3.3 shows the axes of the robot’s object space in black. Clearly, the robot thinks that her y-axis points from her feet to her head and that her x-axis points to her left. The robot’s inertial space is obtained from her object space by rotating her object axes about their origin until the axes are parallel with the world axes (Figure 3.4). Finally, inertial space can be transformed to world space by moving the origin of inertial space to the origin of world space (Figure 3.5). We will return to this concept in Section 3.5.
28
Chapter 3: Multiple Coordinate SpacesFigure 3.2: Object, inertial, and world spaces
TEAM
FLY
Chapter 3: Multiple Coordinate Spaces
29
Figure 3.3: The robot’s object spaceFigure 3.4: The robot’s inertial space