Circle to oriented rectangle
Testing if a point intersects an oriented rectangle involves moving the point into the local space of the oriented rectangle. Once in the oriented rectangle's local space, we treated the oriented rectangle as a non-oriented rectangle. Testing for intersection between a circle and an oriented rectangle works the same way. We move both the circle and oriented rectangle into the rectangle's local space, then perform a circle rectangle intersection test:
Getting ready
We are going to implement a test to see if a circle and oriented rectangle are intersecting. For the sake of convenience, we are also creating a #define
macro as an alias for the function. The code to move the circle into the local space of the oriented rectangle should look familiar by now.
How to do it…
Follow these steps to implement a function which tests for intersection between a circle and an oriented rectangle:
Declare the circle oriented rectangle test in
Geometry2D.h
, also create an alias for this...