Public Member Functions | Private Attributes | Related Functions
vgl_line_segment_2d< Type > Class Template Reference

Represents a 2D line segment using two points. More...

#include <vgl_line_segment_2d.h>

List of all members.

Public Member Functions

 vgl_line_segment_2d ()
 Default constructor - does not initialise!.
 vgl_line_segment_2d (vgl_line_segment_2d< Type > const &l)
 Copy constructor.
 vgl_line_segment_2d (vgl_point_2d< Type > const &p1, vgl_point_2d< Type > const &p2)
 Construct from two end points.
 ~vgl_line_segment_2d ()
 Destructor.
vgl_point_2d< Type > point1 () const
 One end-point of the line segment.
vgl_point_2d< Type > point2 () const
 The other end-point of the line segment.
bool operator== (vgl_line_segment_2d< Type > const &l) const
 The equality comparison operator.
bool operator!= (vgl_line_segment_2d< Type >const &other) const
 The inequality comparison operator.
Type a () const
 Parameter a of line a*x + b*y + c = 0.
Type b () const
 Parameter b of line a*x + b*y + c = 0.
Type c () const
 Parameter c of line a*x + b*y + c = 0.
vgl_vector_2d< Type > direction () const
 unit vector describing line direction.
vgl_vector_2d< Type > normal () const
 unit vector orthogonal to line.
double slope_radians () const
 angle with the oriented horizontal line y=0, measured in radians.
double slope_degrees () const
 angle with the oriented horizontal line y=0, measured in 360-degrees.
void set (vgl_point_2d< Type > const &p1, vgl_point_2d< Type > const &p2)
 Assignment.
vgl_point_2d< Type > point_t (const double t) const
 Return a point on the line defined by a scalar parameter t.

Private Attributes

vgl_point_2d< Type > point1_
 One end of line segment.
vgl_point_2d< Type > point2_
 The other end of the line segment.

Related Functions

(Note that these are not member functions.)

template<class T >
vgl_point_2d< T > vgl_closest_point (vgl_line_segment_2d< T > const &l, vgl_point_2d< T > const &p)
 Return the closest point on a line segment l to a point p in 2D.
template<class T >
double vgl_distance (vgl_line_segment_2d< T > const &l, vgl_point_2d< T > const &p)
 Closest distance from a point p to a line segment l in 2D.
template<class T >
unsigned vgl_intersection (vgl_box_2d< T > const &box, vgl_line_segment_2d< T > const &line, vgl_point_2d< T > &p0, vgl_point_2d< T > &p1)
 Returns the number of intersections of a line segment with a box, up to two are returned in p0 and p1.
template<class Type >
vcl_ostream & operator<< (vcl_ostream &s, const vgl_line_segment_2d< Type > &p)
 Write to stream.
template<class Type >
vcl_istream & operator>> (vcl_istream &is, vgl_line_segment_2d< Type > &p)
 Read from stream.
template<class T >
bool vgl_lineseg_test_line (vgl_line_2d< T > const &l1, vgl_line_segment_2d< T > const &l2)
 true if the line meets the linesegment.
template<class T >
export bool vgl_lineseg_test_point (vgl_point_2d< T > const &p, vgl_line_segment_2d< T > const &lseg)
 true if the point lies on the line segment and is between the endpoints.
template<class T >
bool vgl_lineseg_test_lineseg (vgl_line_segment_2d< T > const &l1, vgl_line_segment_2d< T > const &l2)
 return true if the two linesegments meet.

Detailed Description

template<class Type>
class vgl_line_segment_2d< Type >

Represents a 2D line segment using two points.

Definition at line 23 of file vgl_line_segment_2d.h.


Constructor & Destructor Documentation

template<class Type>
vgl_line_segment_2d< Type >::vgl_line_segment_2d ( ) [inline]

Default constructor - does not initialise!.

Definition at line 32 of file vgl_line_segment_2d.h.

template<class Type>
vgl_line_segment_2d< Type >::vgl_line_segment_2d ( vgl_line_segment_2d< Type > const &  l) [inline]

Copy constructor.

Definition at line 35 of file vgl_line_segment_2d.h.

template<class Type>
vgl_line_segment_2d< Type >::vgl_line_segment_2d ( vgl_point_2d< Type > const &  p1,
vgl_point_2d< Type > const &  p2 
) [inline]

Construct from two end points.

Definition at line 39 of file vgl_line_segment_2d.h.

template<class Type>
vgl_line_segment_2d< Type >::~vgl_line_segment_2d ( ) [inline]

Destructor.

Definition at line 44 of file vgl_line_segment_2d.h.


Member Function Documentation

template<class Type >
Type vgl_line_segment_2d< Type >::a ( ) const

Parameter a of line a*x + b*y + c = 0.

Definition at line 25 of file vgl_line_segment_2d.txx.

template<class Type >
Type vgl_line_segment_2d< Type >::b ( ) const

Parameter b of line a*x + b*y + c = 0.

Definition at line 31 of file vgl_line_segment_2d.txx.

template<class Type >
Type vgl_line_segment_2d< Type >::c ( ) const

Parameter c of line a*x + b*y + c = 0.

Definition at line 37 of file vgl_line_segment_2d.txx.

template<class Type >
vgl_vector_2d< Type > vgl_line_segment_2d< Type >::direction ( ) const

unit vector describing line direction.

Definition at line 43 of file vgl_line_segment_2d.txx.

template<class Type >
vgl_vector_2d< Type > vgl_line_segment_2d< Type >::normal ( ) const

unit vector orthogonal to line.

Definition at line 50 of file vgl_line_segment_2d.txx.

template<class Type>
bool vgl_line_segment_2d< Type >::operator!= ( vgl_line_segment_2d< Type >const &  other) const [inline]

The inequality comparison operator.

Definition at line 58 of file vgl_line_segment_2d.h.

template<class Type>
bool vgl_line_segment_2d< Type >::operator== ( vgl_line_segment_2d< Type > const &  l) const [inline]

The equality comparison operator.

Definition at line 53 of file vgl_line_segment_2d.h.

template<class Type>
vgl_point_2d<Type> vgl_line_segment_2d< Type >::point1 ( ) const [inline]

One end-point of the line segment.

Definition at line 47 of file vgl_line_segment_2d.h.

template<class Type>
vgl_point_2d<Type> vgl_line_segment_2d< Type >::point2 ( ) const [inline]

The other end-point of the line segment.

Definition at line 50 of file vgl_line_segment_2d.h.

template<class Type>
vgl_point_2d<Type> vgl_line_segment_2d< Type >::point_t ( const double  t) const [inline]

Return a point on the line defined by a scalar parameter t.

t=0.0 corresponds to point1 and t=1.0 to point2. 0<t<1 for points on the segment between point1 and point2. t<0 for points on the (infinite) line, outside the segment, and closer to point1 than to point2. t>1 for points on the (infinite) line, outside the segment, and closer to point2 than to point1.

Definition at line 94 of file vgl_line_segment_2d.h.

template<class Type>
void vgl_line_segment_2d< Type >::set ( vgl_point_2d< Type > const &  p1,
vgl_point_2d< Type > const &  p2 
) [inline]

Assignment.

Definition at line 86 of file vgl_line_segment_2d.h.

template<class Type >
double vgl_line_segment_2d< Type >::slope_degrees ( ) const

angle with the oriented horizontal line y=0, measured in 360-degrees.

Returns values between -180 and 180.

Definition at line 57 of file vgl_line_segment_2d.txx.

template<class Type >
double vgl_line_segment_2d< Type >::slope_radians ( ) const

angle with the oriented horizontal line y=0, measured in radians.

Returns values between -pi and pi.

Definition at line 72 of file vgl_line_segment_2d.txx.


Friends And Related Function Documentation

template<class Type >
vcl_ostream & operator<< ( vcl_ostream &  s,
const vgl_line_segment_2d< Type > &  p 
) [related]

Write to stream.

template<class Type >
vcl_istream & operator>> ( vcl_istream &  is,
vgl_line_segment_2d< Type > &  p 
) [related]

Read from stream.

template<class T >
vgl_point_2d< T > vgl_closest_point ( vgl_line_segment_2d< T > const &  l,
vgl_point_2d< T > const &  p 
) [related]

Return the closest point on a line segment l to a point p in 2D.

See also:
vgl_distance_to_linesegment()
template<class T >
double vgl_distance ( vgl_line_segment_2d< T > const &  l,
vgl_point_2d< T > const &  p 
) [related]

Closest distance from a point p to a line segment l in 2D.

See also:
vgl_distance_to_linesegment()
vgl_distance2_to_linesegment()
template<class T >
unsigned vgl_intersection ( vgl_box_2d< T > const &  box,
vgl_line_segment_2d< T > const &  line,
vgl_point_2d< T > &  p0,
vgl_point_2d< T > &  p1 
) [related]

Returns the number of intersections of a line segment with a box, up to two are returned in p0 and p1.

template<class T >
bool vgl_lineseg_test_line ( vgl_line_2d< T > const &  l1,
vgl_line_segment_2d< T > const &  l2 
) [related]

true if the line meets the linesegment.

End points are considered to belong to a line segment.

Definition at line 39 of file vgl_lineseg_test.h.

template<class T >
bool vgl_lineseg_test_lineseg ( vgl_line_segment_2d< T > const &  l1,
vgl_line_segment_2d< T > const &  l2 
) [related]

return true if the two linesegments meet.

End points are considered to belong to a line segment.

Definition at line 61 of file vgl_lineseg_test.h.

template<class T >
bool vgl_lineseg_test_point ( vgl_point_2d< T > const &  p,
vgl_line_segment_2d< T > const &  lseg 
) [related]

true if the point lies on the line segment and is between the endpoints.

Definition at line 88 of file vgl_lineseg_test.txx.


Member Data Documentation

template<class Type>
vgl_point_2d<Type> vgl_line_segment_2d< Type >::point1_ [private]

One end of line segment.

Definition at line 26 of file vgl_line_segment_2d.h.

template<class Type>
vgl_point_2d<Type> vgl_line_segment_2d< Type >::point2_ [private]

The other end of the line segment.

Definition at line 28 of file vgl_line_segment_2d.h.


The documentation for this class was generated from the following files: