# 3D Maths Primer - Multiple Coordinate Systems

This article contains my reading notes from the third chapter of the book 3D Math Primer for Graphics and Game Development, 2nd edition. The subject of the chapter is Multiple Coordinate Systems.

### Multiple Coordinate Systems

The reason multiple coordinate spaces are used is that certain pieces of information are known only in the context of a particular reference frame. It might be true that theoretically all points could be expressed using a single " "world" coordinate system. However, for a certain point a, we may not know the coordinates of a in the "world" coordinate system. But we may be able to express a relative to some other coordinate system.

### Common Coordinate Systems

#### World Space

The world coordinate system is a special coordinate system that establishes the “global” reference frame for all other coordinate systems to be specified.

#### 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.

#### Camera Space

One especially important example of an object space is camera space, which is the object space associated with the viewpoint used for rendering. Note carefully the differences between camera space, which is a 3D space, and screen space, which is a 2D space. The mapping of camera-space coordinates to screen-space coordinates involves an operation known as projection.

#### Upright Space

When communicating either to human beings via words or to computers via code, it is helpful to associate with each object a new coordinate space, which we call the upright coordinate space of the object. An object’s upright space is, in a certain sense, “halfway” between world space and its object space. The axes of upright space are parallel with the axes of world space, but the origin of upright space is coincident with the origin of object space.

Why is upright space interesting? To transform a point between object space and upright space requires only rotation, and to transform a point between upright space and world space requires only a change of location, which is usually called a translation. Thinking about these two things independently is easier than trying to cope with them both at once.

### Coordinate Space Transformations

Do we have to rotate first, and then translate? The answer to this question is basically yes. Although it may seem more natural to translate before rotating, it’s usually easier to rotate first. Here’s why. When we rotate the object first, the center of rotation is the origin. Rotation about the origin and translation are two primitive tools we have at our disposal, and each is easy.

Specifying the position of the coordinate space is straightforward. All we have to do is describe the location of the origin. We do this just like we do for any other point. Of course, we must express this point relative to the parent coordinate space, not the local child space. The origin of the child space, by definition, is always (0, 0, 0) when expressed in child coordinate space.

Specifying the orientation of a coordinate space in 3D is only slightly more complicated. The axes are vectors (directions), and can be specified like any other direction vector. Just as with position, we do not use the object space itself to describe the object-space axis directions, since those coordinates are [1, 0] and [0, 1] by definition. Instead, the coordinates are specified in upright space.