Class Line2D

Inheritance Relationships

Base Type

  • public cv::Vec< double, 3 >

Derived Type

Class Documentation

class Line2D : public cv::Vec<double, 3>

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

Subclassed by tuw::LineSegment2D

Public Functions

Line2D()

constructor

Line2D(const Line2D &l)

copy constructor

Parameters:

l – equation

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

constructor with optional normalization

Parameters:
  • l – equation

  • normalize – normalizes equation on true

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

  • normalize – normalizes equation on true

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

constructor to create a line from points

Parameters:
  • pt1

  • pt2

  • normalize – normalizes equation on true

double &a()
Returns:

the first equation component for x

const double &a() const
Returns:

the first equation component for x

double &b()
Returns:

the second equation component for y

const double &b() const
Returns:

the second equation component for y

double &c()
Returns:

the third equation component

const double &c() const
Returns:

the third equation component

void normalize()

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

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

computes the distance to a point

Parameters:
  • x

  • y

Returns:

the minimal distance to a point

Pre:

normalize

double distanceTo(const Point2D &p) const

computes the distance to a point

Parameters:

p

Returns:

the minimal distance to a point

Pre:

normalize

Pre:

normalize

Point2D 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

Pre:

normalize

Pre:

pointOnLine

Point2D 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

Pre:

normalize

Pre:

pointOnLine

Point2D intersection(const Line2D &l) const

computes the intersection point of two lines

Parameters:

l

Returns:

point on line

Pre:

normalize

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

restuns the normal vector to a line

Returns:

vector

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

  • normalize – normalizes equation on true

Returns:

ref to this

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

constructor to create a line from points

Parameters:
  • p0

  • p1

  • normalize – normalizes equation on true

Returns:

ref to this

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

returns the corresponding opencv vector

Returns:

cv vector

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

returns the corresponding opencv vector

Returns:

cv vector

Polar2D toPolar() const

converts the line into polar coordinates

Returns:

Polar2D

Friends

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