The Line class keeps a point and a vector. For the Line object to be valid, the vector must not be null. More...
#include <line.H>
Inheritance diagram for mlib::Line< L, P, V >:
Public Member Functions | |
Constructors | |
Line () | |
Default constructor. Creates a line with the results of the default constructors for the point and vector classes used. | |
Line (const P &p, const V &v) | |
Constructor that creates a line containing the point p and moving along the direction of vector v . Alternately creates a line segment with p as one endpoint and ( p + v ) as the other endpoint. | |
Line (const P &p1, const P &p2) | |
Constructor that creates the line going through points p1 and p2 . Alternately creates a line segment with endpoints p1 and p2 . | |
Accessor Functions | |
const P & | point () const |
P & | point () |
const V & | vector () const |
V & | vector () |
Line Property Queries | |
bool | is_valid () const |
Is the line valid (i.e. has a vector with non-zero length). | |
P | endpt () const |
Returns the second endpoint of the line when treated as a line segment. | |
P | midpt () const |
Returns the midpoint of the line when treated as a line segment. | |
double | length () const |
Returns the length of the line when treated as a line segment. | |
Overloaded Comparison Operators | |
bool | operator== (const Line< L, P, V > &l) const |
Are the two line's points and vectors exactly equal? | |
Line Operations | |
double | dist (const P &p) const |
Returns the distance from the point to the line. | |
Nearest Point Functions | |
Functions that find the nearest point on the line/line segment to something else. | |
P | project (const P &p) const |
Returns closest point on line to given point p. | |
P | project_to_seg (const P &p) const |
Finds the nearest point on this line segment to the given point. | |
P | project_to_seg (const L &l) const |
Finds the nearest point on this line segment to the given line. | |
Reflection Functions | |
Functions that find the reflection over a line. | |
P | reflection (const P &p) const |
Intersection Functions | |
P | intersect (const L &l) const |
Returns the closest point on this line to the given line l. | |
bool | intersect_segs (const L &l, P &inter) const |
Returns true if this line, treated as a segment, intersects the given line, also treated as a segment. | |
bool | intersect_seg_line (const L &l, P &inter) const |
Returns true if this line, treated as a segment, intersects the given line, also treated as a line. | |
bool | intersect_segs (const L &l) const |
Same as Line<L,P,V>::intersect_segLine(const L& l, P& inter) except without the argument to return the intersection point. | |
Protected Attributes | |
P | _point |
V | _vector |
Related Functions | |
(Note that these are not member functions.) | |
ostream & | operator<< (ostream &os, const Line< L, P, V > &l) |
Stream insertion operator for Line class. |
The Line class keeps a point and a vector. For the Line object to be valid, the vector must not be null.
The Line class is designed to be the base class of more specific types of lines. Specifically, lines in different coordinate systems with different numbers of dimensions. The template argument L is the type of the derived line class. This allows Line to return new lines of the same type as the derived class. The template arguments P and V are the types of the corresponding point and vector classes (respectively) for the coordinate system and number of dimensions of the derived line class.
Definition at line 32 of file line.H.
|
Default constructor. Creates a line with the results of the default constructors for the point and vector classes used. This most likely creates an invalid line (i.e. has a zero length vector) at the origin. |
|
Constructor that creates a line containing the point
|
|
Constructor that creates the line going through points
|
|
Returns the distance from the point to the line. If vector is null (line is not valid) returns distance to _point. |
|
Returns the second endpoint of the line when treated as a line segment.
Definition at line 77 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::reflection(). |
|
Returns the closest point on this line to the given line l. For 3D lines it's rare that the 2 lines actually intersect, so this is not really named well. Definition at line 162 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::intersect_seg_line(), mlib::Line< NDCline, NDCpt, NDCvec >::intersect_segs(), and mlib::Line< NDCline, NDCpt, NDCvec >::project_to_seg(). |
|
Returns true if this line, treated as a segment, intersects the given line, also treated as a line. On success, also fills in the intersection point. |
|
Same as Line<L,P,V>::intersect_segLine(const L& l, P& inter) except without the argument to return the intersection point.
|
|
Returns true if this line, treated as a segment, intersects the given line, also treated as a segment. On success, also fills in the intersection point. Definition at line 187 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::intersect_segs(). |
|
Is the line valid (i.e. has a vector with non-zero length).
|
|
Returns the length of the line when treated as a line segment.
|
|
Returns the midpoint of the line when treated as a line segment.
|
|
Are the two line's points and vectors exactly equal?
|
|
|
|
Definition at line 62 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::intersect(), mlib::Line< NDCline, NDCpt, NDCvec >::intersect_seg_line(), mlib::Line< NDCline, NDCpt, NDCvec >::intersect_segs(), mlib::operator *(), operator>>(), and Bedge::view_intersect(). |
|
Returns closest point on line to given point p. If vector is null (line is not valid) returns _point. Definition at line 116 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::dist(), and mlib::Line< NDCline, NDCpt, NDCvec >::reflection(). |
|
Finds the nearest point on this line segment to the given line. If this line is invalid, returns first endpoint. |
|
Finds the nearest point on this line segment to the given point. If this line is invalid, returns first endpoint. Definition at line 124 of file line.H. Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::project_to_seg(). |
|
Definition at line 144 of file line.H. Referenced by GESTURE::reflect_points(). |
|
|
|
|
Stream insertion operator for Line class.
|
|
|