Public Member Functions | Friends | List of all members
tuw::Line2D Class Reference

#include <line2d.h>

Inheritance diagram for tuw::Line2D:
Inheritance graph
[legend]

Public Member Functions

double & a ()
 
const double & a () const
 
double & b ()
 
const double & b () const
 
double & c ()
 
const double & c () const
 
cv::Vec< double, 3 > & cv ()
 
const cv::Vec< double, 3 > & cv () const
 
double distanceTo (const double &x, const double &y) const
 
double distanceTo (const Point2D &p) const
 
Point2D intersection (const Line2D &l) const
 
 Line2D ()
 constructor More...
 
 Line2D (const Line2D &l)
 
 Line2D (cv::Vec< double, 3 > &l, bool normalize=true)
 
 Line2D (const double &x0, const double &y0, const double &x1, const double &y1, bool normalize=true)
 
 Line2D (const Point2D &pt1, const Point2D &pt2, bool normalize=true)
 
cv::Vec< double, 2 > normal () const
 
void normalize ()
 
Point2D pointOnLine (const double &x, const double &y) const
 
Point2D pointOnLine (const Point2D &p) const
 
Line2Dset (const double &x0, const double &y0, const double &x1, const double &y1, bool normalize=true)
 
Line2Dset (const Point2D &p0, const Point2D &p1, bool normalize=true)
 
Polar2D toPolar () const
 

Friends

std::ostream & operator<< (std::ostream &os, const Line2D &o)
 

Detailed Description

class to represent a 2D line as equation a*x + b*y + c = 0 The line has no endpoints

Definition at line 16 of file line2d.h.

Constructor & Destructor Documentation

Line2D::Line2D ( )

constructor

Definition at line 5 of file line2d.cpp.

Line2D::Line2D ( const Line2D l)

copy constructor

Parameters
lequation

Definition at line 7 of file line2d.cpp.

Line2D::Line2D ( cv::Vec< double, 3 > &  l,
bool  normalize = true 
)

constructor with optional normalization

Parameters
lequation
normalizenormalizes equation on true

Definition at line 9 of file line2d.cpp.

Line2D::Line2D ( const double &  x0,
const double &  y0,
const double &  x1,
const double &  y1,
bool  normalize = true 
)

constructor to create a line from points

Parameters
x0
y0
x1
y1
normalizenormalizes equation on true

Definition at line 13 of file line2d.cpp.

Line2D::Line2D ( const Point2D pt1,
const Point2D pt2,
bool  normalize = true 
)

constructor to create a line from points

Parameters
pt1
pt2
normalizenormalizes equation on true

Definition at line 16 of file line2d.cpp.

Member Function Documentation

double & Line2D::a ( )
Returns
the first equation component for x

Definition at line 19 of file line2d.cpp.

const double & Line2D::a ( ) const
Returns
the first equation component for x

Definition at line 22 of file line2d.cpp.

double & Line2D::b ( )
Returns
the second equation component for y

Definition at line 25 of file line2d.cpp.

const double & Line2D::b ( ) const
Returns
the second equation component for y

Definition at line 28 of file line2d.cpp.

double & Line2D::c ( )
Returns
the third equation component

Definition at line 31 of file line2d.cpp.

const double & Line2D::c ( ) const
Returns
the third equation component

Definition at line 34 of file line2d.cpp.

cv::Vec< double, 3 > & Line2D::cv ( )

returns the corresponding opencv vector

Returns
cv vector

Definition at line 72 of file line2d.cpp.

const cv::Vec< double, 3 > & Line2D::cv ( ) const

returns the corresponding opencv vector

Returns
cv vector

Definition at line 75 of file line2d.cpp.

double Line2D::distanceTo ( const double &  x,
const double &  y 
) const

computes the distance to a point

Parameters
x
y
Returns
the minimal distance to a point
Precondition
normalize

Definition at line 41 of file line2d.cpp.

double Line2D::distanceTo ( const Point2D p) const

computes the distance to a point

Parameters
p
Returns
the minimal distance to a point
Precondition
normalize
normalize

Definition at line 45 of file line2d.cpp.

Point2D Line2D::intersection ( const Line2D l) const

computes the intersection point of two lines

Parameters
l
Returns
point on line
Precondition
normalize

Definition at line 57 of file line2d.cpp.

cv::Vec< double, 2 > Line2D::normal ( ) const

restuns the normal vector to a line

Returns
vector

Definition at line 61 of file line2d.cpp.

void Line2D::normalize ( )

normalizes the equation to a*a + b*b = 1

Definition at line 37 of file line2d.cpp.

Point2D Line2D::pointOnLine ( const double &  x,
const double &  y 
) const

computes a point on the line with the shortest distance to the point given

Parameters
x
y
Returns
point on line
Precondition
normalize
pointOnLine

Definition at line 49 of file line2d.cpp.

Point2D Line2D::pointOnLine ( const Point2D p) const

computes a point on the line with the shortest distance to the point given

Parameters
p
Returns
point on line
Precondition
normalize
pointOnLine

Definition at line 54 of file line2d.cpp.

Line2D & Line2D::set ( const double &  x0,
const double &  y0,
const double &  x1,
const double &  y1,
bool  normalize = true 
)

constructor to create a line from points

Parameters
x0
y0
x1
y1
normalizenormalizes equation on true
Returns
ref to this

cross product with homogenios vectors

Definition at line 64 of file line2d.cpp.

Line2D & Line2D::set ( const Point2D p0,
const Point2D p1,
bool  normalize = true 
)

constructor to create a line from points

Parameters
p0
p1
normalizenormalizes equation on true
Returns
ref to this

Definition at line 69 of file line2d.cpp.

Polar2D Line2D::toPolar ( ) const

converts the line into polar coordinates

Returns
Polar2D

Definition at line 78 of file line2d.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Line2D o 
)
friend

Definition at line 152 of file line2d.h.


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


tuw_geometry
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:33:09