LineSegment2D Class Reference

A segment of a straight line in the 2D plane. More...

#include <MBARI/Geometry2D.H>

Collaboration diagram for LineSegment2D:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LineSegment2D ()
 default constructor, constructs an invalid object
 LineSegment2D (const Point2D< int > &p1, const Point2D< int > &p2)
 construct from two Point2D<int>
 LineSegment2D (std::istream &is)
 Construct from the data contained in the input stream is.
void reset (const Point2D< int > &point, const Point2D< int > &direction)
 reset the straight line
void writeToStream (std::ostream &os) const
 write the entire StraightLine2D to the output stream os
void readFromStream (std::istream &is)
 read the StraightLine2D from the input stream is
Point2D< int > point1 () const
 get a point on the line
Point2D< int > point2 () const
 returns the direction vector for this straight line
double angle () const
 returns the angle of the line
double angleBetween (LineSegment2D &line) const
bool intersects (LineSegment2D &line, double &xcoord, double &ycoord) const
double distance (Point2D< double > point) const
double distance (Point2D< int > point) const
float length () const
bool isValid () const
 whether this object is valid

Detailed Description

A segment of a straight line in the 2D plane.

Definition at line 233 of file Geometry2D.H.


Constructor & Destructor Documentation

LineSegment2D::LineSegment2D (  ) 

default constructor, constructs an invalid object

Definition at line 437 of file Geometry2D.C.

LineSegment2D::LineSegment2D ( const Point2D< int > &  p1,
const Point2D< int > &  p2 
)

construct from two Point2D<int>

Parameters:
p1 an endpoint on the line
p2 the second endpoint of the line line

Definition at line 442 of file Geometry2D.C.

LineSegment2D::LineSegment2D ( std::istream &  is  ) 

Construct from the data contained in the input stream is.

Definition at line 448 of file Geometry2D.C.

References readFromStream().


Member Function Documentation

double LineSegment2D::angle (  )  const

returns the angle of the line

Definition at line 500 of file Geometry2D.C.

References Point2D< T >::i, point1(), and point2().

bool LineSegment2D::intersects ( LineSegment2D line,
double &  xcoord,
double &  ycoord 
) const

returns true if the two line segments intersect. x and y are set to be the point of intersection of the lines, whether or not the segments themselves intersect.

Definition at line 524 of file Geometry2D.C.

References Point2D< T >::i, isFinite(), point1(), point2(), and sqrt().

bool LineSegment2D::isValid (  )  const

whether this object is valid

Definition at line 519 of file Geometry2D.C.

Referenced by point1(), and point2().

Point2D< int > LineSegment2D::point1 (  )  const

get a point on the line

Parameters:
n get point point + n * direction; for n = 0 (default), this is the point entered in the constructor or in reset

Definition at line 486 of file Geometry2D.C.

References ASSERT, and isValid().

Referenced by angle(), and intersects().

Point2D< int > LineSegment2D::point2 (  )  const

returns the direction vector for this straight line

Definition at line 493 of file Geometry2D.C.

References ASSERT, and isValid().

Referenced by angle(), and intersects().

void LineSegment2D::readFromStream ( std::istream &  is  ) 

read the StraightLine2D from the input stream is

Definition at line 477 of file Geometry2D.C.

Referenced by LineSegment2D().

void LineSegment2D::reset ( const Point2D< int > &  point,
const Point2D< int > &  direction 
)

reset the straight line

Parameters:
point vector determining a point on the line
direction vector determing the direction if the line

Definition at line 454 of file Geometry2D.C.

void LineSegment2D::writeToStream ( std::ostream &  os  )  const

write the entire StraightLine2D to the output stream os

Definition at line 468 of file Geometry2D.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3