![]() |
Vault
4.1
|
VLineT defines a line segment with two points. More...
#include <vgeometry.h>
Public Member Functions | |
| VLineT (VPointT< T > start, VPointT< T > end) | |
| VLineT (VPointT< T > start, VSizeT< T > vec) | |
| VLineT (T x1, T y1, T x2, T y2) | |
| VLineT (T x1, T y1, VSizeT< T > vec) | |
| VLineT (VBinaryIOStream &stream) | |
| void | readFromStream (VBinaryIOStream &stream) |
| void | writeToStream (VBinaryIOStream &stream) const |
| VPointT< T > | getP1 () const |
| VPointT< T > | getP2 () const |
| void | setP1 (VPointT< T > p) |
| void | setP2 (VPointT< T > p) |
| void | setPoints (VPointT< T > p1, VPointT< T > p2) |
| VPointT< T > & | rP1 () |
| VPointT< T > & | rP2 () |
| VSizeT< T > | getSize () const |
| T | getDX () const |
| T | getDY () const |
| VDouble | getLength () const |
| void | translate (const VPointT< T > &delta) |
| void | translate (T deltaX, T deltaY) |
| VLineT< T > | translated (const VPointT< T > &delta) const |
| VLineT< T > | translated (T deltaX, T deltaY) const |
| VLineT< T > | normalized () const |
| Normalizes the line in the following sense: The resulting line's P1 and P2 will point left-to-right (+x), and if the x values are the same, it will point top-to-bottom (+y). | |
| VLineT< T > | reversed () const |
| VLineT< VDouble > | getUnitVector () const |
| Returns a VLine starting at P1, towards P2 but with length 1.0. | |
| VPoint | getNearestPoint (const VPoint &C, bool restrictToSegment) const |
| Returns the point on this line (AB) that is the nearest to the supplied point C. | |
| VDouble | getDistanceToPoint (const VPoint &p, bool restrictToSegment) const |
Static Public Member Functions | |
| static bool | equal (const VLineT< T > &line1, const VLineT< T > &line2) |
| static bool | notEqual (const VLineT< T > &line1, const VLineT< T > &line2) |
| static bool | same (const VLineT< T > &line1, const VLineT< T > &line2) |
| Returns true if the two lines have the same endpoints (within 0.000001), regardless of their order. | |
Friends | |
| bool | operator== (const VLineT< T > &line1, const VLineT< T > &line2) |
| bool | operator!= (const VLineT< T > &line1, const VLineT< T > &line2) |
VLineT defines a line segment with two points.
The order matters for equality and math. Use the same() function to test equality without respect to the order of the two points. VLine uses VDouble coordinates; VILine uses int coordinates.
Definition at line 331 of file vgeometry.h.
Normalizes the line in the following sense: The resulting line's P1 and P2 will point left-to-right (+x), and if the x values are the same, it will point top-to-bottom (+y).
This can be useful when comparing or using two lines when you don't want the "directionality" of the line to matter.
Definition at line 374 of file vgeometry.h.
Returns a VLine starting at P1, towards P2 but with length 1.0.
Definition at line 392 of file vgeometry.h.
| static bool VLineT< T >::same | ( | const VLineT< T > & | line1, |
| const VLineT< T > & | line2 | ||
| ) | [inline, static] |
Returns true if the two lines have the same endpoints (within 0.000001), regardless of their order.
| line1 | a line |
| line2 | a line |
Definition at line 415 of file vgeometry.h.
| VPoint VLineT< T >::getNearestPoint | ( | const VPoint & | C, |
| bool | restrictToSegment | ||
| ) | const [inline] |
Returns the point on this line (AB) that is the nearest to the supplied point C.
You can specify whether this line is treated as a line segment (result within the segment) or not (result may be outside the segment). Note the input and result points are VPoint, not VPointT<T>, because even if this line is integer-based, the result may not be.
| C | a point to test |
| restrictToSegment | true if the result must lie between endpoints |
Definition at line 439 of file vgeometry.h.