public final class Line extends Object
Modifier and Type | Method and Description |
---|---|
static Vec4[] |
clipToFrustum(Vec4 pa,
Vec4 pb,
Frustum frustum)
Clip a line segment to a frustum, returning the end points of the portion of the segment that is within the
frustum.
|
double |
distanceTo(Vec4 p)
Calculate the shortests distance between this line and a specified
Vec4 . |
static double |
distanceToSegment(Vec4 p0,
Vec4 p1,
Vec4 p) |
boolean |
equals(Object o)
Performs a comparison to test whether this Object is internally identical to the other Object
o . |
static Line |
fromSegment(Vec4 pa,
Vec4 pb)
Create the line containing a line segement between two points.
|
Vec4 |
getDirection() |
Vec4 |
getOrigin() |
Vec4 |
getPointAt(double t) |
int |
hashCode() |
boolean |
isPointBehindLineOrigin(Vec4 point)
Determine if a point is behind the
Line 's origin. |
Vec4 |
nearestIntersectionPoint(Intersection[] intersections) |
static Vec4 |
nearestPointOnSegment(Vec4 p0,
Vec4 p1,
Vec4 p)
Finds the closest point to a third point of a segment defined by two points.
|
Vec4 |
nearestPointTo(Vec4 p) |
double |
selfDot() |
String |
toString() |
public Line(Vec4 origin, Vec4 direction)
origin
- the origin of the line being constructeddirection
- the direction of the line being constructedIllegalArgumentException
- if origin
is null, or direction
is null or has zero
lengthpublic static Vec4[] clipToFrustum(Vec4 pa, Vec4 pb, Frustum frustum)
pa
- the first point of the segment.pb
- the second point of the segment.frustum
- the frustum.public final double distanceTo(Vec4 p)
Vec4
. This method returns a
positive distance.p
- the Vec4
whose distance from this Line
will be calculatedLine
and the specified Vec4
IllegalArgumentException
- if p
is nullpublic final boolean equals(Object o)
o
.
This method takes into account both direction and origin, so two lines which may be equivalent may not be
considered equal.public static Line fromSegment(Vec4 pa, Vec4 pb)
pa
- the first point of the line segment.pb
- the second point of the line segment.IllegalArgumentException
- if either point is null or they are coincident.public final Vec4 getDirection()
public final Vec4 getOrigin()
public final Vec4 getPointAt(double t)
public boolean isPointBehindLineOrigin(Vec4 point)
Line
's origin.point
- The point to test.point
is behind this Line
's origin, false otherwise.public Vec4 nearestIntersectionPoint(Intersection[] intersections)
public static Vec4 nearestPointOnSegment(Vec4 p0, Vec4 p1, Vec4 p)
p0
- The first endpoint of the segment.p1
- The second endpoint of the segment.p
- The point outside the segment whose closest point on the segment is desired.public final double selfDot()