Public Member Functions | Private Attributes | Related Functions | List of all members
vgl_line_segment_2d< Type > Class Template Reference

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

#include <vgl_fwd.h>

Inheritance diagram for vgl_line_segment_2d< Type >:
Inheritance graph
[legend]

Public Member Functions

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

Private Attributes

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

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. More...
 
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. More...
 
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. More...
 
template<class Type >
std::ostream & operator<< (std::ostream &s, const vgl_line_segment_2d< Type > &p)
 Write to stream. More...
 
template<class Type >
std::istream & operator>> (std::istream &is, vgl_line_segment_2d< Type > &p)
 Read from stream. More...
 
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. More...
 
template<class T >
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. More...
 
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. More...
 

Detailed Description

template<class Type>
class vgl_line_segment_2d< Type >

Represents a 2D line segment using two points.

Definition at line 18 of file vgl_fwd.h.

Constructor & Destructor Documentation

◆ vgl_line_segment_2d() [1/3]

template<class Type>
vgl_line_segment_2d< Type >::vgl_line_segment_2d ( )
inlinedefault

Default constructor - does not initialise!.

◆ vgl_line_segment_2d() [2/3]

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.

◆ vgl_line_segment_2d() [3/3]

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.

◆ ~vgl_line_segment_2d()

template<class Type>
vgl_line_segment_2d< Type >::~vgl_line_segment_2d ( )
inlinedefault

Destructor.

Member Function Documentation

◆ a()

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

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

Definition at line 38 of file vgl_line_segment_2d.hxx.

◆ b()

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

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

Definition at line 44 of file vgl_line_segment_2d.hxx.

◆ c()

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

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

Definition at line 50 of file vgl_line_segment_2d.hxx.

◆ direction()

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

unit vector describing line direction.

Definition at line 56 of file vgl_line_segment_2d.hxx.

◆ normal()

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

unit vector orthogonal to line.

Definition at line 63 of file vgl_line_segment_2d.hxx.

◆ operator!=()

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.

◆ operator==()

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.

◆ point1()

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.

◆ point2()

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.

◆ point_t()

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.

◆ set()

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.

◆ slope_degrees()

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 70 of file vgl_line_segment_2d.hxx.

◆ slope_radians()

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 85 of file vgl_line_segment_2d.hxx.

Friends And Related Function Documentation

◆ operator<<()

template<class Type >
std::ostream & operator<< ( std::ostream &  s,
const vgl_line_segment_2d< Type > &  p 
)
related

Write to stream.

◆ operator>>()

template<class Type >
std::istream & operator>> ( std::istream &  is,
vgl_line_segment_2d< Type > &  p 
)
related

Read from stream.

◆ vgl_closest_point()

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

◆ vgl_distance()

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

◆ vgl_intersection()

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.

(warning! one intersection could be either p0 or p1).

◆ vgl_lineseg_test_line()

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 42 of file vgl_lineseg_test.h.

◆ vgl_lineseg_test_lineseg()

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 64 of file vgl_lineseg_test.h.

◆ vgl_lineseg_test_point()

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 91 of file vgl_lineseg_test.hxx.

Member Data Documentation

◆ point1_

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.

◆ point2_

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: