geom::Line Struct Reference

A class representing a line as two end points. More...

#include <geom.hh>

List of all members.

Public Member Functions

 Line ()
 Create a line.
 Line (Point a, Point b)
 Create a line.
 Line (float x1, float y1, float x2, float y2)
 Create a line.
 Line (const LineRT &line)
 Create a line by converting from the polar representation (rho, theta).
void add (Point p, float scale=1)
 Add a point to the end points of the line.
float length () const
 Compute the length of the line.
Point normal () const
 Compute the normal of the line.
Point tangent () const
 Compute the tangent of the line.
Point intersection (const Line &line) const
 Compute the intersection with line.
Linecut (const Line &line1, const Line &line2)
 Cut the line between two lines.
Line get_cut (const Line &line1, const Line &line2) const
 Compute the cut of the line between two lines.
Point closest (const Point &point) const
 Compute the point on the line that is closest to point.
Point mirror (const Point &point, float scale=1) const
 Mirror a point with respect to the line.
Linemirror (const Line &mirror, float scale=1)
 Mirror the line with respect to the given line.
Line get_mirror (const Line &mirror) const
 Return the line mirrored with respect to the given line.
template<typename T>
T & map (T &obj)
 Map the integer points of the line.

Public Attributes

Point a
 The first end point.
Point b
 The second end point.


Detailed Description

A class representing a line as two end points.


Constructor & Destructor Documentation

geom::Line::Line Point  a,
Point  b
[inline]
 

Create a line.

Parameters:
a = the first end point
b = the second end point

geom::Line::Line float  x1,
float  y1,
float  x2,
float  y2
[inline]
 

Create a line.

Parameters:
x1 = the first end point
y1 = the first end point
x2 = the second end point
y2 = the second end point

geom::Line::Line const LineRT line  )  [inline]
 

Create a line by converting from the polar representation (rho, theta).

Note:
The end points of the resulting line are guaranteed to be on the line, but consider the actual positions to be arbitrary.


Member Function Documentation

void geom::Line::add Point  p,
float  scale = 1
[inline]
 

Add a point to the end points of the line.

Parameters:
p = the point to add to the line
scale = the scaling of the point before adding

Point geom::Line::closest const Point point  )  const [inline]
 

Compute the point on the line that is closest to point.

Parameters:
point = the point
Returns:
the point closest to point

Line& geom::Line::cut const Line line1,
const Line line2
[inline]
 

Cut the line between two lines.

The first point will be the intersection with the first line, and the second point will be the intersection with the second line.

Parameters:
line1 = the first line
line2 = the second line

Line geom::Line::get_cut const Line line1,
const Line line2
const [inline]
 

Compute the cut of the line between two lines.

The first point will be the intersection with the first line, and the second point will be the intersection with the second line.

Parameters:
line1 = the first line
line2 = the second line

Line geom::Line::get_mirror const Line mirror  )  const [inline]
 

Return the line mirrored with respect to the given line.

Parameters:
mirror = the mirror line

Point geom::Line::intersection const Line line  )  const [inline]
 

Compute the intersection with line.

Parameters:
line = the line to intersect with
Returns:
the intersection point

template<typename T>
T& geom::Line::map T &  obj  )  [inline]
 

Map the integer points of the line.

The method calls obj(x, y) for each integer point of the line.

Bug:
The float coordinates should be handled more elegantly so that the line is processed along the longer axis and the other coordinate is computed for each middle location.
Parameters:
obj = the object to call for each line point
Returns:
a reference to the object obj

Line& geom::Line::mirror const Line mirror,
float  scale = 1
[inline]
 

Mirror the line with respect to the given line.

Parameters:
mirror = the mirror line
scale = scale for the mirroring

Point geom::Line::mirror const Point point,
float  scale = 1
const [inline]
 

Mirror a point with respect to the line.

Parameters:
point = point to mirror
scale = scale for the mirroring

Point geom::Line::normal  )  const [inline]
 

Compute the normal of the line.

Note that the length of the normal is not normalized to one.

Returns:
the normal of the line

Point geom::Line::tangent  )  const [inline]
 

Compute the tangent of the line.

Note that the length of the tangent is not normalized to one.

Returns:
the tangent of the line


The documentation for this struct was generated from the following file:
Generated on Tue Apr 8 09:58:19 2008 for GoCam by  doxygen 1.4.6