Skip to main content

3D Math Primer - Vectors

This article contains my reading notes from the second chapter of the book 3D Math Primer for Graphics and Game Development, 2nd edition. The subject of the chapter is Vectors, and the chapter starts with the basic properties of vectors. Below I have noted some important (to me) definitions.

As the subject of the book is graphics, the coverage is focused on the geometric interpretations of vectors and vector operations. Geometrically speaking, a vector is a directed line segment that has magnitude and direction.

For any given vector dimension, there is a special vector, known as the zero vector, that has zeroes in every position. The zero vector has zero magnitude, and no direction. Think of the zero vector as a way to express the concept of "no displacement", much as the scalar zero stands for the concept of "no quantity". Below is the three-dimensional zero vector:

\[ \boldsymbol{0} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ \end{bmatrix} \]

It is important to understand that points and vectors are conceptually distinct, but mathematically equivalent. When you think of a location, think of a point and visualize a dot. When you think of a displacement, think of a vector and visualize an arrow. The math we develop in the following sections operates on "vectors" rather than "points". Keep in mind that any point can be represented as a vector from the origin.

Negating a vector results in a vector of the same magnitude but opposite direction. We negate a vector by negating each component of it, i.e.:

\[ - \begin{bmatrix} 2 \\ 2 \\ \end{bmatrix} = \begin{bmatrix} -2 \\ -2 \\ \end{bmatrix} \]

A vector can be multiplied by a scalar, and this will change the magnitude of the vector, and possibly the direction as well.

Read more…

3D Math Primer - Cartesian Coordinate Systems

At work I am currently doing simulation and rendering of 3D models, and need to brush up on related mathematics. I was recommended a book on the subject called 3D Math Primer for Graphics and Game Development, 2nd edition. Although the title contains the words game development, the main focus of the book is on 3D math and the geometry and algebra of 3D space. It is also written in an informal and relaxed style, making it a fun read as well as a useful one.

I will chronicle my learning journey here.

1D Mathematics

The book starts with the absolute basics covering 1D mathematics and number lines (with the numbers represented as dead sheep, and negative numbers as ghost sheep). At this point it was becoming obvious that this was no regular textbook, but although the language is tongue-in-cheek, the book is a thorough treatment of the subject matter. The chapter quickly convers natural numbers, real numbers and rational numbers.

2D Cartesian Space

The book moves on to 2D Cartesian Space, and quickly covers origins, axes and axes orientation. We quickly learn that axes orientation is an arbitrary concept, and that it 2D space we can alway rotate the coordinate space to whatever orientation we want.

3D Cartesian Space

Adding a third axis to a plane creating a 3D space increases the difficulty for humans to visualize and describe the space. In 3D space points are specified using the numbers \(x\), \(y\) and \(z\), which give the signed distance to the planes \(yz\), \(xz\) and \(xy\) planes respectively.

All 3D coordinate spaces are not equal. While 2D coordinate spaces can always be rotated to line up with each other, this is not the case with 3D coordinate spaces. There are two distinct types, left-handed coordinate spaces and right-handed coordinate spaces. If two coordinate spaces have the same handedness, they can always be rotated so that the axes are aligned, but if they are of opposite handedness, this is not possible.

The easiest way to visualize this is having the thumb, index and middle finger pointing in perpendicular directions, signalling the positive direction of the three axes. The left and the right hand can never have the same orientation for all the three axes at the same time.

The definition of positive rotation is also different for left- and right-handed coordinate systems. Holding the hand with the thumb up, and the direction of the thumb representing the positive side of the axis, positive rotation around the axis is the direction in which the other fingers are curled.


The final part of the chapter gives a brief overview of trigonometric functions, their values and properties as they relate to 3D Math.