After point containment, the line intersection the is the next logical intersection test to implement. Knowing if a line intersects one of the basic 2D primitives is very useful, and in most cases rather straightforward to implement.
We are going to implement functions to test if a line is intersecting any of the basic 2D primitives. To keep the naming of these functions a little more convenient, we are going to use the
#define macro to create aliases for each function.
How to do it…
Follow these steps to test if a line intersects any of the two-dimensional primitives we have defined so far:
- Declare the line test functions in
bool LineCircle(const Line2D& line, const Circle& circle); bool LineRectangle(const ...