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

Represents a Euclidean 2D line. More...

#include <vgl_fwd.h>

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

Public Member Functions

 vgl_line_2d ()
 Default constructor (Line 1.y==0, the X axis). More...
 
 vgl_line_2d (Type ta, Type tb, Type tc)
 Construct a vgl_line_2d from its equation, three Types. More...
 
 vgl_line_2d (const Type v[3])
 Construct from its equation, a 3-vector. More...
 
 vgl_line_2d (vgl_homg_line_2d< Type > const &l)
 Construct from homogeneous description of line. More...
 
 vgl_line_2d (vgl_point_2d< Type > const &p1, vgl_point_2d< Type > const &p2)
 Construct from two distinct points (join). More...
 
 vgl_line_2d (vgl_point_2d< Type > const &p, vgl_vector_2d< Type > const &v)
 Construct from one point and one vector. More...
 
bool operator== (vgl_line_2d< Type > const &l) const
 the comparison operator. More...
 
bool operator!= (vgl_line_2d< Type >const &other) const
 
double slope_radians () const
 angle with the horizontal line y=0, measured in radians. More...
 
double slope_degrees () const
 angle with the horizontal line y=0, measured in 360-degrees. 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...
 
bool normalize ()
 normalize the line coefficients s.t. a^2 + b^2 = 1. More...
 
void set (Type ta, Type tb, Type tc)
 Set a b c. More...
 
bool ideal (Type=(Type) 0) const
 Return true iff this line is the line at infinity. More...
 
void get_two_points (vgl_point_2d< Type > &p1, vgl_point_2d< Type > &p2) const
 Get two points on the line; normally the intersection with X and Y axes. More...
 

Private Attributes

Type a_
 
Type b_
 
Type c_
 

Related Functions

(Note that these are not member functions.)

template<class T >
vgl_point_2d< T > vgl_closest_point (vgl_line_2d< T > const &l, vgl_point_2d< T > const &p)
 Return the point on the given line closest to the given point. More...
 
template<class T >
double vgl_distance_origin (vgl_line_2d< T > const &l)
 find the shortest distance of the line to the origin. More...
 
template<class T >
double vgl_distance (vgl_line_2d< T > const &l, vgl_point_2d< T > const &p)
 return the perpendicular distance from a point to a line in 2D. More...
 
template<class T >
bool vgl_intersection (vgl_box_2d< T > const &box, vgl_line_2d< T > const &line, vgl_point_2d< T > &p0, vgl_point_2d< T > &p1)
 Return true if line intersects box. If so, compute intersection points. More...
 
template<class T >
bool vgl_intersection (vgl_box_2d< T > const &box, vgl_line_segment_2d< T > const &line, vgl_line_segment_2d< T > &int_line)
 Return true if line intersects box.If so,return the line segment inside box. More...
 
template<class T >
bool vgl_intersection (vgl_line_2d< T > const &line0, vgl_line_2d< T > const &line1, vgl_point_2d< T > &intersection_point)
 Return the intersection point of two lines. Return false if lines are parallel. More...
 
template<class Type >
bool is_ideal (l const &, Type=(Type) 0)
 Return true iff line is the line at infinity. More...
 
template<class Type >
bool concurrent (l const &l1, l const &l2, l const &l3)
 Are three lines concurrent, i.e., do they pass through a common point?. More...
 
template<class Type >
std::ostream & operator<< (std::ostream &s, l const &line)
 Write line description to stream: "<vgl_line_2d ax+by+c>". More...
 
template<class Type >
std::istream & operator>> (std::istream &s, l &line)
 Read in three line parameters from stream. More...
 

Detailed Description

template<class Type>
class vgl_line_2d< Type >

Represents a Euclidean 2D line.

An interface for the line coefficients, [a,b,c], is provided in terms of the standard implicit line equation: a*x + b*y + c = 0

Definition at line 16 of file vgl_fwd.h.

Constructor & Destructor Documentation

◆ vgl_line_2d() [1/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( )
inline

Default constructor (Line 1.y==0, the X axis).

Definition at line 43 of file vgl_line_2d.h.

◆ vgl_line_2d() [2/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( Type  ta,
Type  tb,
Type  tc 
)
inline

Construct a vgl_line_2d from its equation, three Types.

The values of a and b should not be both zero.

Definition at line 47 of file vgl_line_2d.h.

◆ vgl_line_2d() [3/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( const Type  v[3])
inline

Construct from its equation, a 3-vector.

The values v[0] and v[1] should not be both zero.

Definition at line 51 of file vgl_line_2d.h.

◆ vgl_line_2d() [4/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( vgl_homg_line_2d< Type > const &  l)

Construct from homogeneous description of line.

The line l should not be the line at infinity.

Definition at line 37 of file vgl_line_2d.hxx.

◆ vgl_line_2d() [5/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( vgl_point_2d< Type > const &  p1,
vgl_point_2d< Type > const &  p2 
)

Construct from two distinct points (join).

line through two given points.

The two points must be distinct!

Definition at line 19 of file vgl_line_2d.hxx.

◆ vgl_line_2d() [6/6]

template<class Type>
vgl_line_2d< Type >::vgl_line_2d ( vgl_point_2d< Type > const &  p,
vgl_vector_2d< Type > const &  v 
)

Construct from one point and one vector.

line defined by one point and one vector.

Definition at line 29 of file vgl_line_2d.hxx.

Member Function Documentation

◆ a()

template<class Type>
Type vgl_line_2d< Type >::a ( ) const
inline

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

Definition at line 97 of file vgl_line_2d.h.

◆ b()

template<class Type>
Type vgl_line_2d< Type >::b ( ) const
inline

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

Definition at line 99 of file vgl_line_2d.h.

◆ c()

template<class Type>
Type vgl_line_2d< Type >::c ( ) const
inline

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

Definition at line 101 of file vgl_line_2d.h.

◆ direction()

template<class Type>
vgl_vector_2d<Type> vgl_line_2d< Type >::direction ( ) const
inline

unit vector describing line direction.

Definition at line 104 of file vgl_line_2d.h.

◆ get_two_points()

template<class Type>
void vgl_line_2d< Type >::get_two_points ( vgl_point_2d< Type > &  p1,
vgl_point_2d< Type > &  p2 
) const

Get two points on the line; normally the intersection with X and Y axes.

Get two points on the line.

When the line is parallel to one of these, the point with y=1 or x=1, resp. are taken. When the line goes through the origin, the second point is (b, -a).

These two points are normally the intersections with the Y axis and X axis, respectively. When the line is parallel to one of these, the point with y=1 or x=1, resp. are taken. When the line goes through the origin, the second point is (b,-a).

Definition at line 50 of file vgl_line_2d.hxx.

◆ ideal()

template<class Type>
bool vgl_line_2d< Type >::ideal ( Type  = (Type)0) const
inline

Return true iff this line is the line at infinity.

This always returns "false"

Definition at line 121 of file vgl_line_2d.h.

◆ normal()

template<class Type>
vgl_vector_2d<Type> vgl_line_2d< Type >::normal ( ) const
inline

unit vector orthogonal to line.

Definition at line 108 of file vgl_line_2d.h.

◆ normalize()

template<class Type >
bool vgl_line_2d< Type >::normalize ( )

normalize the line coefficients s.t. a^2 + b^2 = 1.

Definition at line 79 of file vgl_line_2d.hxx.

◆ operator!=()

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

Definition at line 80 of file vgl_line_2d.h.

◆ operator==()

template<class Type>
bool vgl_line_2d< Type >::operator== ( vgl_line_2d< Type > const &  l) const
inline

the comparison operator.

Definition at line 74 of file vgl_line_2d.h.

◆ set()

template<class Type>
void vgl_line_2d< Type >::set ( Type  ta,
Type  tb,
Type  tc 
)
inline

Set a b c.

The values of a and b should not be both zero. Note that it does not make sense to set a, b or c separately

Definition at line 117 of file vgl_line_2d.h.

◆ slope_degrees()

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

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

Returns values between -180 and 180, i.e., the lines x-y=0 and y-x=0 return different values (45 and -135 respectively) although these lines are identical.

Definition at line 60 of file vgl_line_2d.hxx.

◆ slope_radians()

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

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

Returns values between -pi and pi, i.e., the lines x-y=0 and y-x=0 return different values (pi/4 and -3pi/4 respectively) although these lines are identical.

Definition at line 73 of file vgl_line_2d.hxx.

Friends And Related Function Documentation

◆ concurrent()

template<class Type >
bool concurrent ( l const &  l1,
l const &  l2,
l const &  l3 
)
related

Are three lines concurrent, i.e., do they pass through a common point?.

Definition at line 140 of file vgl_line_2d.h.

◆ is_ideal()

template<class Type >
bool is_ideal ( l const &  ,
Type  = (Type)0 
)
related

Return true iff line is the line at infinity.

Definition at line 135 of file vgl_line_2d.h.

◆ operator<<()

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

Write line description to stream: "<vgl_line_2d ax+by+c>".

◆ operator>>()

template<class Type >
std::istream & operator>> ( std::istream &  s,
l line 
)
related

Read in three line parameters from stream.

Either just reads three blank-separated numbers, or reads three comma-separated numbers, or reads three numbers in parenthesized form "(123, 321, -456)" or reads a formatted line equation "123x+321y-456=0"

◆ vgl_closest_point()

template<class T >
vgl_point_2d< T > vgl_closest_point ( vgl_line_2d< T > const &  l,
vgl_point_2d< T > const &  p 
)
related

Return the point on the given line closest to the given point.

◆ vgl_distance()

template<class T >
double vgl_distance ( vgl_line_2d< T > const &  l,
vgl_point_2d< T > const &  p 
)
related

return the perpendicular distance from a point to a line in 2D.

◆ vgl_distance_origin()

template<class T >
double vgl_distance_origin ( vgl_line_2d< T > const &  l)
related

find the shortest distance of the line to the origin.

◆ vgl_intersection() [1/3]

template<class T >
bool vgl_intersection ( vgl_box_2d< T > const &  box,
vgl_line_2d< T > const &  line,
vgl_point_2d< T > &  p0,
vgl_point_2d< T > &  p1 
)
related

Return true if line intersects box. If so, compute intersection points.

◆ vgl_intersection() [2/3]

template<class T >
bool vgl_intersection ( vgl_box_2d< T > const &  box,
vgl_line_segment_2d< T > const &  line,
vgl_line_segment_2d< T > &  int_line 
)
related

Return true if line intersects box.If so,return the line segment inside box.

◆ vgl_intersection() [3/3]

template<class T >
bool vgl_intersection ( vgl_line_2d< T > const &  line0,
vgl_line_2d< T > const &  line1,
vgl_point_2d< T > &  intersection_point 
)
related

Return the intersection point of two lines. Return false if lines are parallel.

Member Data Documentation

◆ a_

template<class Type>
Type vgl_line_2d< Type >::a_
private

Definition at line 37 of file vgl_line_2d.h.

◆ b_

template<class Type>
Type vgl_line_2d< Type >::b_
private

Definition at line 38 of file vgl_line_2d.h.

◆ c_

template<class Type>
Type vgl_line_2d< Type >::c_
private

Definition at line 39 of file vgl_line_2d.h.


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