# Vector Math for 3D Computer Graphics

### Fourth Revision, July 2009

This is a tutorial on vector algebra and matrix algebra from the viewpoint of computer graphics. It covers most vector and matrix topics needed to read college-level computer graphics text books. Most graphics texts cover these subjects in an appendix, but it is often too short. This tutorial covers the same material at greater length, and with many examples.

A mirror site that contains this material is: Mirror Site

 · Chapter 0 — Points and Lines · Chapter 1 — Vectors, Points, and Column Matrices · Chapter 2 — Matrix Addition · Chapter 3 — Vector Addition · Chapter 4 — Vector Length · Chapter 5 — Vector Direction · Chapter 6 — Scaling and Unit Vectors · Chapter 7 — The Dot Product · Chapter 8 — Length and the Dot Product · Chapter 9 — The Angle between Two Vectors · Chapter 10 — The Angle between 3D Vectors · Chapter 11 — Projecting one Vector onto Another · Chapter 12 — Vector Cross Product · Chapter 13 — Matrices and Simple Matrix Operations · Chapter 14 — Matrix-Column Matrix Multiplicaton · Chapter 15 — Matrix-Matrix Multiplication · Chapter 16 — Identity Matrix and Matrix Inverse · Index

Computer graphics requires more math than is covered here. The purpose of these notes is to expand on the mathematical appendix included with most graphics books, not to teach the mathematical material in the main text of those books.

Although primarily aimed at university computer science students, this tutorial is useful to any programmer interested in 3D computer graphics or 3D computer game programming. In spite of their appealing blood-and-gore covers, mass trade books on game programming require the same understanding of vectors and matrices as college text books (and usually defer these topics to the same skimpy mathematical appendix).

This tutorial is useful for more than computer graphics. Vectors and matrices are used in all scientific and engineering fields, and any other field that uses computers (are there any that don't?) In many fields, the vocabulary used for vectors and matrices does not match that used in computer graphics. But the ideas are the same, and reading these notes will take only a slight mental adjustment.

These notes assume that you have studied plane geometry and trigonometry sometime in the past. Notions such as point, line, plane, and angle should be familiar to you. Other notions such as sine, cosine, determinant, real number, and the common trig identities should at least be a distant memory.

These pages were designed at 800 by 600 resolution. They have been (somewhat) tested with not-too-old versions of Firefox and Internet Explorer. Many pages require Javascript, and some pages require Java. If you lack these (or are behind a firewall that blocks these) you will be able to read most pages, but the interactive features will be lost.

Some sections are years old and have been used in class many times (and hence are "classroom tested" and likely to be technically correct and readable). Other sections are more recent and might fall short of both goals.