2D points

A point is the simplest two-dimensional primitive we can implement. It is infinitely small; it has x and y coordinates. A good way to think of a 2D point is like an alternate representation of a 2D vector. A vector points to somewhere in space; a point is where the vector points to:

2D points

Getting ready

Since this is the first geometry object we are creating, we also need to create a new header file, Geometry2D.h. All future 2D geometry and intersection tests will be added to this file. Because a point has the same definition as a 2D vector, we're not going to create a new structure; instead we will redefine the vec2 struct as Point2D.

How to do ...

Get Game Physics Cookbook 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.