Circle

A circle is defined by a point in space and a Radius. The circle is an extremely simple shape as shown in the following diagram:

Circle

Getting ready

Intersection algorithms for the circle are as simple as its definition. For this reason, a circle is often the first choice to approximate the bounding volume of objects. Arguably, the circle is the most commonly used 2D primitive.

How to do it…

Follow these steps to implement a two-dimensional circle:

  1. Start the declaration of the Circle structure in Geometry2D.h by creating the variables that make up a circle:
    typedef struct Circle {
       Point2D position;
       float radius;
  2. Next, declare an inline constructor that ...

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.