JNR
|
2D line segment More...
#include <laLine2.h>
Public Member Functions | |
laPoint2 | normal (int direction=1) const |
Get a perpendicular vector of lenght 1 (normal of the line segment) | |
int | direction (const laPoint2 &pt) const |
M_BOOL | onSameSide (const laPoint2 &a, const laPoint2 &b) const |
Check if two points are on the same side of the line. | |
M_BOOL | intersection (const laLine2 &ln, double *k, double *k_ln) const |
double | distance (laPoint2 &pt) const |
Compute the distance between a point and the line. | |
double | distance_sq (laPoint2 &pt) const |
Compute the square of the distance between a point and the line. | |
void | draw (class laRenderer *r, laPoint2 &pos) |
Draw the line ( primarily for debug purposes ) | |
Line constructors and initialization methods | |
laLine2 (void) | |
laLine2 (const laPoint2 &a, const laPoint2 &b) | |
void | build (const laPoint2 &a, const laPoint2 &b) |
Build a line from two end-points. | |
void | build_v (const laPoint2 &a, const laPoint2 &v) |
Build a line from an end-point and a vector. | |
Lenght of the segment | |
double | lenght () const |
double | lenght_sq () const |
Squared root of segment lenght. | |
Getting points at different positions on the line | |
laPoint2 | end () const |
Get the end-point. | |
void | at (double k, laPoint2 *ppt) const |
Get point at 1/k lenght (returns in user-specified pointer) More... | |
const laPoint2 | at (double k) const |
double | getX (double k) const |
Get X at 1/k lenght. | |
double | getY (double k) const |
Get Y at 1/k lenght. | |
Getting the parameter k at specified XY coordinates | |
double | getK (const laPoint2 &pt) const |
double | getK_atX (double x) const |
double | getK_atY (double y) const |
Static Public Member Functions | |
static void | drawLine2s (laLine2 *arLines, unsigned n, class laRenderer *r, laPoint2 &pos) |
Draw many lines ( primarily for debug purposes ) | |
Public Attributes | |
laPoint2 | origin |
Point of origin. | |
laPoint2 | vector |
Vector ( not normalized, so k = [0;1] traces the whole line segment ) | |
|
inline |
Get point at 1/k lenght (returns in user-specified pointer)
Get point at 1/k lenght (retruns a new object)
Definition at line 81 of file laLine2.h.
Referenced by distance(), distance_sq(), and intersection().
|
inline |
Get {+1; -1} depending on the side of the line where a point resides. NOTE: This can be used to reason about the relative position of two points
Definition at line 123 of file laLine2.h.
Referenced by normal(), and onSameSide().
|
inline |
Find the point of intersection with another line segment; If the vectors are parallel, returns false; Otherwise returns parameters k and k_ln, corresponding to positions along the two line segments.
Definition at line 149 of file laLine2.h.
Referenced by distance(), and distance_sq().