

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object com.vividsolutions.jts.geom.LineSegment
Represents a line segment defined by two Coordinate
s.
Provides methods to compute various geometric properties
and relationships of line segments.
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 Coordinate
s.
Field Summary  
Coordinate 
p0

Coordinate 
p1

Constructor Summary  
LineSegment()


LineSegment(Coordinate p0,
Coordinate p1)


LineSegment(LineSegment ls)

Method Summary  
double 
angle()
Computes the angle that the vector defined by this segment makes with the Xaxis. 
Coordinate 
closestPoint(Coordinate p)
Computes the closest point on this line segment to another point. 
Coordinate[] 
closestPoints(LineSegment line)
Computes the closest points on two line segments. 
int 
compareTo(java.lang.Object o)
Compares this object with the specified object for order. 
double 
distance(Coordinate p)
Computes the distance between this line segment and a given point. 
double 
distance(LineSegment ls)
Computes the distance between this line segment and another segment. 
double 
distancePerpendicular(Coordinate p)
Computes the perpendicular distance between the (infinite) line defined by this line segment and a point. 
boolean 
equals(java.lang.Object o)
Returns true if other has the same values for
its points. 
boolean 
equalsTopo(LineSegment other)
Returns true if other is
topologically equal to this LineSegment (e.g. 
Coordinate 
getCoordinate(int i)

double 
getLength()
Computes the length of the line segment. 
Coordinate 
intersection(LineSegment line)
Computes an intersection point between two segments, if there is one. 
boolean 
isHorizontal()
Tests whether the segment is horizontal. 
boolean 
isVertical()
Tests whether the segment is vertical. 
Coordinate 
midPoint()
Computes the midpoint of the segment 
void 
normalize()
Puts the line segment into a normalized form. 
int 
orientationIndex(LineSegment seg)
Determines the orientation of a LineSegment relative to this segment. 
Coordinate 
pointAlong(double segmentLengthFraction)
Computes the Coordinate that lies a given
fraction along the line defined by this segment. 
Coordinate 
project(Coordinate p)
Compute the projection of a point onto the line determined by this line segment. 
LineSegment 
project(LineSegment seg)
Project a line segment onto this line segment and return the resulting line segment. 
double 
projectionFactor(Coordinate p)
Computes the Projection Factor for the projection of the point p onto this LineSegment. 
void 
reverse()
Reverses the direction of the line segment. 
void 
setCoordinates(Coordinate p0,
Coordinate p1)

void 
setCoordinates(LineSegment ls)

java.lang.String 
toString()

Methods inherited from class java.lang.Object 
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Field Detail 
public Coordinate p0
public Coordinate p1
Constructor Detail 
public LineSegment(Coordinate p0, Coordinate p1)
public LineSegment(LineSegment ls)
public LineSegment()
Method Detail 
public Coordinate getCoordinate(int i)
public void setCoordinates(LineSegment ls)
public void setCoordinates(Coordinate p0, Coordinate p1)
public double getLength()
public boolean isHorizontal()
true
if the segment is horizontalpublic boolean isVertical()
true
if the segment is verticalpublic int orientationIndex(LineSegment seg)
seg
 the LineSegment to compare
seg
is to the left of this segmentpublic void reverse()
public void normalize()
Coordinate
).
public double angle()
public Coordinate midPoint()
public double distance(LineSegment ls)
public double distance(Coordinate p)
public double distancePerpendicular(Coordinate p)
public Coordinate pointAlong(double segmentLengthFraction)
Coordinate
that lies a given
fraction along the line defined by this segment.
A fraction of 0.0
returns the start point of the segment;
a fraction of 1.0
returns the end point of the segment.
segmentLengthFraction
 the fraction of the segment length along the line
public double projectionFactor(Coordinate p)
public Coordinate project(Coordinate p)
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].
public LineSegment project(LineSegment seg)
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.
seg
 the line segment to project
null
if there is no overlappublic Coordinate closestPoint(Coordinate p)
p
 the point to find the closest point to
public Coordinate[] closestPoints(LineSegment line)
public Coordinate intersection(LineSegment line)
RobustLineIntersector
class should be used.
line

null
if there is nonepublic boolean equals(java.lang.Object o)
true
if other
has the same values for
its points.
true
if other
is a LineSegment
with the same values for the x and y ordinates.public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
 the LineSegment
with which this LineSegment
is being compared
LineSegment
is less than, equal to, or greater than the specified LineSegment
public boolean equalsTopo(LineSegment other)
true
if other
is
topologically equal to this LineSegment (e.g. irrespective
of orientation).
other
 a LineSegment
with which to do the comparison.
true
if other
is a LineSegment
with the same values for the x and y ordinates.public java.lang.String toString()


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 