Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mlib::Line< L, P, V > Class Template Reference
[MLIB]

Templated class defining an oriented line and/or a line segment.

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 >:

Inheritance graph
[legend]
Collaboration diagram for mlib::Line< L, P, V >:

Collaboration graph
[legend]
List of all members.

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).
endpt () const
 Returns the second endpoint of the line when treated as a line segment.
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.

project (const P &p) const
 Returns closest point on line to given point p.
project_to_seg (const P &p) const
 Finds the nearest point on this line segment to the given point.
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.

reflection (const P &p) const
Intersection Functions
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

_point
_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.

Detailed Description

template<class L, class P, class V>
class mlib::Line< L, P, V >

Templated class defining an oriented line and/or a line segment.

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.


Constructor & Destructor Documentation

template<class L, class P, class V>
mlib::Line< L, P, V >::Line  )  [inline]
 

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.

Definition at line 44 of file line.H.

template<class L, class P, class V>
mlib::Line< L, P, V >::Line const P &  p,
const V &  v
[inline]
 

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.

Definition at line 50 of file line.H.

template<class L, class P, class V>
mlib::Line< L, P, V >::Line const P &  p1,
const P &  p2
[inline]
 

Constructor that creates the line going through points p1 and p2. Alternately creates a line segment with endpoints p1 and p2.

Definition at line 55 of file line.H.


Member Function Documentation

template<class L, class P, class V>
double mlib::Line< L, P, V >::dist const P &  p  )  const [inline]
 

Returns the distance from the point to the line.

If vector is null (line is not valid) returns distance to _point.

Definition at line 104 of file line.H.

template<class L, class P, class V>
P mlib::Line< L, P, V >::endpt  )  const [inline]
 

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().

template<class L, class P, class V>
P mlib::Line< L, P, V >::intersect const L &  l  )  const [inline]
 

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().

template<class L, class P, class V>
bool mlib::Line< L, P, V >::intersect_seg_line const L &  l,
P &  inter
const [inline]
 

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.

Definition at line 210 of file line.H.

template<class L, class P, class V>
bool mlib::Line< L, P, V >::intersect_segs const L &  l  )  const [inline]
 

Same as Line<L,P,V>::intersect_segLine(const L& l, P& inter) except without the argument to return the intersection point.

Definition at line 229 of file line.H.

template<class L, class P, class V>
bool mlib::Line< L, P, V >::intersect_segs const L &  l,
P &  inter
const [inline]
 

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().

template<class L, class P, class V>
bool mlib::Line< L, P, V >::is_valid  )  const [inline]
 

Is the line valid (i.e. has a vector with non-zero length).

Definition at line 73 of file line.H.

template<class L, class P, class V>
double mlib::Line< L, P, V >::length  )  const [inline]
 

Returns the length of the line when treated as a line segment.

Definition at line 84 of file line.H.

template<class L, class P, class V>
P mlib::Line< L, P, V >::midpt  )  const [inline]
 

Returns the midpoint of the line when treated as a line segment.

Definition at line 81 of file line.H.

template<class L, class P, class V>
bool mlib::Line< L, P, V >::operator== const Line< L, P, V > &  l  )  const [inline]
 

Are the two line's points and vectors exactly equal?

Definition at line 92 of file line.H.

template<class L, class P, class V>
P& mlib::Line< L, P, V >::point  )  [inline]
 

Definition at line 63 of file line.H.

template<class L, class P, class V>
const P& mlib::Line< L, P, V >::point  )  const [inline]
 

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().

template<class L, class P, class V>
P mlib::Line< L, P, V >::project const P &  p  )  const [inline]
 

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().

template<class L, class P, class V>
P mlib::Line< L, P, V >::project_to_seg const L &  l  )  const [inline]
 

Finds the nearest point on this line segment to the given line.

If this line is invalid, returns first endpoint.

Definition at line 134 of file line.H.

template<class L, class P, class V>
P mlib::Line< L, P, V >::project_to_seg const P &  p  )  const [inline]
 

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().

template<class L, class P, class V>
P mlib::Line< L, P, V >::reflection const P &  p  )  const [inline]
 

Definition at line 144 of file line.H.

Referenced by GESTURE::reflect_points().

template<class L, class P, class V>
V& mlib::Line< L, P, V >::vector  )  [inline]
 

Definition at line 65 of file line.H.

template<class L, class P, class V>
const V& mlib::Line< L, P, V >::vector  )  const [inline]
 

Definition at line 64 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 mlib::Line< NDCline, NDCpt, NDCvec >::reflection().


Friends And Related Function Documentation

template<class L, class P, class V>
ostream & operator<< ostream &  os,
const Line< L, P, V > &  l
[related]
 

Stream insertion operator for Line class.

Definition at line 254 of file line.H.


Member Data Documentation

template<class L, class P, class V>
P mlib::Line< L, P, V >::_point [protected]
 

Definition at line 238 of file line.H.

Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::endpt(), mlib::Line< NDCline, NDCpt, NDCvec >::midpt(), mlib::Line< NDCline, NDCpt, NDCvec >::operator==(), mlib::Line< NDCline, NDCpt, NDCvec >::point(), mlib::Line< NDCline, NDCpt, NDCvec >::project(), and mlib::Line< NDCline, NDCpt, NDCvec >::project_to_seg().

template<class L, class P, class V>
V mlib::Line< L, P, V >::_vector [protected]
 

Definition at line 239 of file line.H.

Referenced by mlib::Line< NDCline, NDCpt, NDCvec >::endpt(), mlib::Line< NDCline, NDCpt, NDCvec >::is_valid(), mlib::Line< NDCline, NDCpt, NDCvec >::length(), mlib::Line< NDCline, NDCpt, NDCvec >::midpt(), mlib::Line< NDCline, NDCpt, NDCvec >::operator==(), mlib::Line< NDCline, NDCpt, NDCvec >::project(), mlib::Line< NDCline, NDCpt, NDCvec >::project_to_seg(), and mlib::Line< NDCline, NDCpt, NDCvec >::vector().


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 11:48:09 2006 for jot by  doxygen 1.4.4