24.1. Vectors and matrices

The Pop Framework uses a cVector class to hold our critters’ positions. Basing the cVector on real numbers helps to make our programs resolution-independent. Also the use of real numbers lets us give our simulated objects more interesting and physically realistic behaviors. We can use cVector for positions, velocities, and accelerations, and, because these vectors are based on real numbers, we can use some standard machinery from mathematics and physics.

We normally define the shape of an object by a collection of vectors near the origin, and then when we want to translate or rotate the object, we imagine transforming these ‘shape vectors’ into some new location. Without going into much detail, let’s assume that you’re ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.