public final class LineSegment
extends java.lang.Object
Constructor and Description |
---|
LineSegment(Point start,
Point end)
Ctor with given start and end point
|
LineSegment(Point start,
Point direction,
double distance)
Ctor with given start point, a point that defines the direction of the line and a length
|
Modifier and Type | Method and Description |
---|---|
LineSegment |
clipToRectangle(Rectangle r)
Intersection of this LineSegment with the Rectangle as another LineSegment.
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
boolean |
intersectsRectangle(Rectangle r,
boolean bias)
Returns a fast computation if the line intersects the rectangle or bias if there
is no fast way to compute the intersection.
|
double |
length()
Euclidian distance between start and end.
|
Point |
pointAlongLineSegment(double distance)
Computes a Point along the line segment with a given distance to the start Point.
|
LineSegment |
reverse()
New line segment with start and end reversed.
|
LineSegment |
subSegment(double offset,
double length)
LineSegment that starts at offset from start and runs for length towards end point
|
java.lang.String |
toString() |
public LineSegment(Point start, Point end)
start
- start pointend
- end pointpublic LineSegment(Point start, Point direction, double distance)
start
- start pointdirection
- point that defines the direction (a line from start to direction point)distance
- how long to move along the line between start and directionpublic LineSegment clipToRectangle(Rectangle r)
r
- the rectangle to clip to.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean intersectsRectangle(Rectangle r, boolean bias)
r
- retangle to testbias
- the result if no fast computation is possiblepublic double length()
public Point pointAlongLineSegment(double distance)
distance
- distance from start pointpublic LineSegment reverse()
public LineSegment subSegment(double offset, double length)
offset
- offset applied at begin of linelength
- length of the new segmentpublic java.lang.String toString()
toString
in class java.lang.Object