#include <LineSegment.h>
Inheritance diagram for geos::geom::LineSegment:
Public Member Functions  
LineSegment ()  
Segemnt end.  
LineSegment (const LineSegment &ls)  
LineSegment (const Coordinate &c0, const Coordinate &c1)  
Constructs a LineSegment with the given start and end Coordinates.  
LineSegment (double x0, double y0, double x1, double y1)  
void  setCoordinates (const Coordinate &c0, const Coordinate &c1) 
const Coordinate &  operator[] (size_t i) const 
Coordinate &  operator[] (size_t i) 
void  setCoordinates (const LineSegment &ls) 
double  getLength () const 
Computes the length of the line segment.  
bool  isHorizontal () const 
Tests whether the segment is horizontal.  
bool  isVertical () const 
Tests whether the segment is vertical.  
int  orientationIndex (const LineSegment &seg) const 
int  orientationIndex (const LineSegment *seg) const 
int  orientationIndex (const Coordinate &p) const 
Determines the orientation index of a Coordinate relative to this segment.  
void  reverse () 
Reverses the direction of the line segment.  
void  normalize () 
Puts the line segment into a normalized form.  
double  angle () const 
void  midPoint (Coordinate &ret) const 
Computes the midpoint of the segment.  
double  distance (const LineSegment &ls) const 
Computes the distance between this line segment and another one.  
double  distance (const Coordinate &p) const 
Computes the distance between this line segment and a point.  
double  distancePerpendicular (const Coordinate &p) const 
Computes the perpendicular distance between the (infinite) line defined by this line segment and a point.  
void  pointAlong (double segmentLengthFraction, Coordinate &ret) const 
Computes the Coordinate that lies a given fraction along the line defined by this segment.  
void  pointAlongOffset (double segmentLengthFraction, double offsetDistance, Coordinate &ret) const 
Computes the Coordinate that lies a given fraction along the line defined by this segment and offset from the segment by a given distance.  
double  projectionFactor (const Coordinate &p) const 
Compute the projection factor for the projection of the point p onto this LineSegment.  
double  segmentFraction (const Coordinate &inputPt) const 
Computes the fraction of distance (in [0.0, 1.0] ) that the projection of a point occurs along this line segment.  
void  project (const Coordinate &p, Coordinate &ret) const 
Compute the projection of a point onto the line determined by this line segment.  
bool  project (const LineSegment &seg, LineSegment &ret) const 
Project a line segment onto this line segment and return the resulting line segment.  
void  closestPoint (const Coordinate &p, Coordinate &ret) const 
Computes the closest point on this line segment to another point.  
int  compareTo (const LineSegment &other) const 
Compares this object with the specified object for order.  
bool  equalsTopo (const LineSegment &other) const 
Returns true if other is topologically equal to this LineSegment (e.g. irrespective of orientation).  
CoordinateSequence *  closestPoints (const LineSegment &line) 
CoordinateSequence *  closestPoints (const LineSegment *line) 
bool  intersection (const LineSegment &line, Coordinate &coord) const 
bool  lineIntersection (const LineSegment &line, Coordinate &coord) const 
Computes the intersection point of the lines defined by two segments, if there is one.  
std::auto_ptr< LineString >  toGeometry (const GeometryFactory &gf) const 
Public Attributes  
Coordinate  p0 
Coordinate  p1 
Segment start.  
Friends  
std::ostream &  operator<< (std::ostream &o, const LineSegment &l) 
This class is designed to be easily mutable (to the extent of having its contained points public). This supports a common pattern of reusing a single LineSegment object as a way of computing segment properties on the segments defined by arrays or lists of Coordinates.
TODO: have this class keep pointers rather then real Coordinates ?



Computes the closest point on this line segment to another point.


Computes the closest points on two line segments.


Compares this object with the specified object for order. Uses the standard lexicographic ordering for the points in the LineSegment.


Returns


Computes an intersection point between two segments, if there is one. There may be 0, 1 or many intersection points between two segments. If there are 0, null is returned. If there is 1 or more, a single one is returned (chosen at the discretion of the algorithm). If more information is required about the details of the intersection, the LineIntersector class should be used.


Tests whether the segment is horizontal.


Tests whether the segment is vertical.


Computes the intersection point of the lines defined by two segments, if there is one.
There may be 0, 1 or an infinite number of intersection points between two lines. If there is a unique intersection point, it is returned. Otherwise,


Computes the midpoint of the segment.


Puts the line segment into a normalized form. This is useful for using line segments in maps and indexes when topological equality rather than exact equality is desired. 

Determines the orientation index of a Coordinate relative to this segment. The orientation index is as defined in CGAlgorithms::computeOrientation.


Determines the orientation of a LineSegment relative to this segment. The concept of orientation is specified as follows: Given two line segments A and L, <ul A is to the left of a segment L if A lies wholly in the closed halfplane lying to the left of L A is to the right of a segment L if A lies wholly in the closed halfplane lying to the right of L otherwise, A has indeterminate orientation relative to L. This happens if A is collinear with L or if A crosses the line determined by L.


Computes the Coordinate that lies a given fraction along the line defined by this segment.
A fraction of


Computes the Coordinate that lies a given fraction along the line defined by this segment and offset from the segment by a given distance.
A fraction of The computed point is offset to the left of the line if the offset distance is positive, to the right if negative.


Project a line segment onto this line segment and return the resulting line segment. The returned line segment will be a subset of the target line line segment. This subset may be null, if the segments are oriented in such a way that there is no projection. Note that the returned line may have zero length (i.e. the same endpoints). This can happen for instance if the lines are perpendicular to one another.


Compute the projection of a point onto the line determined by this line segment. Note that the projected point may lie outside the line segment. If this is the case, the projection factor will lie outside the range [0.0, 1.0]. 

Compute the projection factor for the projection of the point p onto this LineSegment. The projection factor is the constant r by which the vector for this segment must be multiplied to equal the vector for the projection of p on the line defined by this segment. The projection factor returned will be in the range (inf, +inf)


Computes the fraction of distance (in
If the point is beyond either ends of the line segment, the closest fractional value (
Essentially, this is the projectionFactor clamped to the range


Creates a LineString with the same coordinates as this segment
