drasys.or.geom.rect2
Class LineSegment

java.lang.Object
  |
  +--drasys.or.geom.rect2.Rect2
        |
        +--drasys.or.geom.rect2.LineSegment

public class LineSegment
extends Rect2
implements LineSegmentI, java.io.Serializable

An implementation of a line segment in the 2D rectangular coordinate system. This lineSegment is a container object, it hold the points that define the ends of the line segment. The points must be objects that implement the PointI interface and have immutable coordinates.

See Also:
Serialized Form

Constructor Summary
LineSegment(double x1, double y1, double x2, double y2)
           
LineSegment(LineSegmentI lineSegment)
           
LineSegment(PointI point1, PointI point2)
           
 
Method Summary
 PointI centroid()
           
 double distanceProxyTo(PointI point)
          Returns an easily computable proxy that can be used to compare the distance from this line segment to the point argument.
 double distanceTo(PointI point)
          Returns the distance from this line segment to the point argument.
 boolean equals(java.lang.Object o)
          Returns true if the two corresponding points in each line segment are equal.
 PointI from()
          Returns the from point of the line segment.
 PointI getPoint1()
          Returns the from point of the line segment.
 PointI getPoint2()
          Returns the to point of the line segment.
 int hashCode()
           
 double length()
          Returns the length of the line segment.
 PointI nearestPointTo(PointI point)
          Returns the point along the segment that is closest to the argument.
 PointI point1()
           
 PointI point2()
           
 RangeI range()
           
 PointI to()
          Returns the to point of the line segment.
 java.lang.String toString()
           
 double x1()
           
 double x2()
           
 double y1()
           
 double y2()
           
 
Methods inherited from class drasys.or.geom.rect2.Rect2
coordinateSystem, getCentroid, getDistanceProxyTo, getDistanceTo, getNearestPointTo, getRange
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineSegment

public LineSegment(double x1,
                   double y1,
                   double x2,
                   double y2)

LineSegment

public LineSegment(PointI point1,
                   PointI point2)

LineSegment

public LineSegment(LineSegmentI lineSegment)
Method Detail

getPoint1

public PointI getPoint1()
Description copied from interface: LineSegmentI
Returns the from point of the line segment.

getPoint2

public PointI getPoint2()
Description copied from interface: LineSegmentI
Returns the to point of the line segment.

point1

public PointI point1()
Specified by:
point1 in interface LineSegmentI

point2

public PointI point2()
Specified by:
point2 in interface LineSegmentI

x1

public double x1()
Specified by:
x1 in interface LineSegmentI

y1

public double y1()
Specified by:
y1 in interface LineSegmentI

x2

public double x2()
Specified by:
x2 in interface LineSegmentI

y2

public double y2()
Specified by:
y2 in interface LineSegmentI

range

public RangeI range()

centroid

public PointI centroid()

from

public PointI from()
Returns the from point of the line segment.

to

public PointI to()
Returns the to point of the line segment.

nearestPointTo

public PointI nearestPointTo(PointI point)
Returns the point along the segment that is closest to the argument.

distanceTo

public double distanceTo(PointI point)
Returns the distance from this line segment to the point argument.

distanceProxyTo

public double distanceProxyTo(PointI point)
Returns an easily computable proxy that can be used to compare the distance from this line segment to the point argument.

length

public double length()
Returns the length of the line segment.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Returns true if the two corresponding points in each line segment are equal. The equality is tested using the 'Point.equals()' static method.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com