Three-dimensional line class. More...
#include <line3.h>
Classes | |
class | BadLine |
Ill-defined line exception. More... |
Public Member Functions | |
Line3 () | |
Line3 (const Unit3 &dir, const Point3 &sup, const DirectionType &type=DIRECTED) | |
Constructor for unit direction vector and support point input. | |
Line3 (const Vector3 &dir, const Point3 &sup, const DirectionType &type=DIRECTED) | |
Constructor for non-unit direction vector and support point input. | |
Line3 (const Point3 ¹, const Point3 ², const DirectionType &type=DIRECTED) | |
Constructor for two support point input. | |
bool | operator== (const Line3 &L) const |
bool | operator!= (const Line3 &L) const |
Point3 | project (const Point3 &p) const |
Projects point p on current line. | |
Scalar | distance (const Point3 &p) const |
Distance from point p to current line. | |
Unit3 | getDirection () const |
Gets line direction unit vector. | |
Unit3 & | getDirectionRef () |
const Unit3 & | getDirectionRef () const |
Point3 | getSupport () const |
Point3 & | getSupportRef () |
const Point3 & | getSupportRef () const |
DirectionType | getDirectionType () const |
Gets line direction type. | |
DirectionType & | getDirectionTypeRef () |
const DirectionType & | getDirectionTypeRef () const |
Point3 | getPoint (const Scalar &t) const |
Scalar | getParameter (const Point3 &p) const |
Gets line parameter associated to a cartesian point. | |
void | setDirection (const Unit3 &dir) |
Sets line direction unit vector. | |
void | setSupport (const Point3 &sup) |
Sets line support point. | |
void | setDirectionType (const DirectionType &type) |
Sets line direction type. | |
void | setValue (const Unit3 &dir, const Point3 &sup, const DirectionType &type=DIRECTED) |
Sets line with direction vector, support point, and direction type. |
Three-dimensional line class.
Lines are represented using the parametric line equation
where
A given line can be represented in infinitely different ways depending on the selected support point. Since the interest is to have a unique line representation regardless of the parameters it was constructed with, a normalized representation of the parametric line equation is used, in which the support point is the line point closest to the current coordinate system. Keep this in mind because when querying for the line support point you will be getting the normalized point instead of the value supplied in the constructor (unless they coincide).
Additionally, a line can be considered to be directed or undirected. If two directed lines differ only in that their direction vectors are antiparallel, they are considered different. If at least one of the lines is undirected, then they are considered to be equal. If left unspecified in the constructor, all lines are considered directed.
After a line is constructed, it is tested to ensure it was well defined. For example, after constructing a line with a direction vector and support point inputs, the support point is tested to ensure it is contained in the line. Another case that can yield an ill-defined situation is a line constructed with two almost-coincident points.
This is an example of how to use the Line3 class:
|
inline |
Default constructor. Creates a directed line coincident with the z axis.
|
inline |
Gets the cartesian point associated to the line parameter t according to .
|
inline |
Gets normalized line support point. Refer to the class description for the meaning of normalized.