Containing circle
One of the necessities for performing real-time collision detection is to simplify a given shape. For this reason, we need to make a function that, given a set of points, will return a circle containing all the points. This simplified bounding circle can then be used to approximate a collision area:

Getting ready
In order to avoid adding a dependency to std::vector
in Geometry2D.h
, we will implement this new function using an array. The ContainingCircle
function will take two arguments, one is a Point2D
array, and the other deals with the number of elements in the array. The ContainingCircle
function will return a bounding circle that encapsulates all of the points.
How to do it…
Follow these steps to implement a function that will build a bounding circle from a set of points:
Declare the
ContainingCircle
function inGeometry2D.h
:Circle ContainingCircle(Point2D* pArray, int arrayCount);
Implement
ContainingCircle
inGeometry2D.cpp
:Circle ContainingCircle(Point2D* pArray, int...