![]() |
The Shapes Library
Game Physics with Bespoke Code
|
Line shape. More...
#include <Line.h>

Public Member Functions | |
| CLine (const Vector2 &, float) | |
| Constructor. | |
Protected Member Functions | |
| const Vector2 | Intersect (const CLine &) const |
| Get intersection point with line. | |
| const Vector2 | ClosestPt (const Vector2 &) const |
| Get closest point on line. | |
A line is infinite in both directions. It consists of its gradient \(m\) and \(y\)-incercept \(c\), that is, it has the equation \(y = mx + c\). The gradient can be infinite, in which case it has the equation \(x = b\), where \(b\) is its \(x\)-intercept. Note that there is no line descriptor class. That is to discourage the use of lines outside this project. If you are thinking of using one, I recommend that you use a line segment instead.
| CLine::CLine | ( | const Vector2 & | p, |
| float | m ) |
Given a point and a gradient, construct the unique line through that point with that gradient.
| p | Point. |
| m | Gradient. |

|
protected |
Given a point, find the point on this line that is closest to it. This is done by intersecting this line with a perpendicular line through the point.
| p | A point. |


|
protected |
Given another line, find the unique point that is on both lines if they are not parallel, otherwise fail. We have to careful whem one or both of the lines are vertical because vertical lines have infinite gradient.
| Line | A line to intersect with. |
