Package gov.nasa.worldwind.geom
Class Line
- java.lang.Object
-
- gov.nasa.worldwind.geom.Line
-
public final class Line extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 specifiedVec4
.static double
distanceToSegment(Vec4 p0, Vec4 p1, Vec4 p)
boolean
equals(java.lang.Object o)
Performs a comparison to test whether this Object is internally identical to the other Objecto
.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 theLine
'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()
java.lang.String
toString()
-
-
-
Method Detail
-
fromSegment
public static Line fromSegment(Vec4 pa, Vec4 pb)
Create the line containing a line segement between two points.- Parameters:
pa
- the first point of the line segment.pb
- the second point of the line segment.- Returns:
- The line containing the two points.
- Throws:
java.lang.IllegalArgumentException
- if either point is null or they are coincident.
-
getDirection
public final Vec4 getDirection()
-
getOrigin
public final Vec4 getOrigin()
-
getPointAt
public final Vec4 getPointAt(double t)
-
selfDot
public final double selfDot()
-
equals
public final boolean equals(java.lang.Object o)
Performs a comparison to test whether this Object is internally identical to the other Objecto
. This method takes into account both direction and origin, so two lines which may be equivalent may not be considered equal.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- the object to be compared against.- Returns:
- true if these two objects are equal, false otherwise
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
distanceTo
public final double distanceTo(Vec4 p)
Calculate the shortests distance between this line and a specifiedVec4
. This method returns a positive distance.- Parameters:
p
- theVec4
whose distance from thisLine
will be calculated- Returns:
- the distance between this
Line
and the specifiedVec4
- Throws:
java.lang.IllegalArgumentException
- ifp
is null
-
nearestPointOnSegment
public static Vec4 nearestPointOnSegment(Vec4 p0, Vec4 p1, Vec4 p)
Finds the closest point to a third point of a segment defined by two points.- Parameters:
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.- Returns:
- The closest point on (p0, p1) to p. Note that this will be p0 or p1 themselves whenever the closest point on the line defined by p0 and p1 is outside the segment (i.e., the results are bounded by the segment endpoints).
-
clipToFrustum
public 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.- Parameters:
pa
- the first point of the segment.pb
- the second point of the segment.frustum
- the frustum.- Returns:
- The two points at which the segment intersects the frustum, or null if the segment does not intersect and the frustum does not fully contain it. If the segment is coincident with a plane of the frustum, the returned segment is the portion of the original segment on that plane, clipped to the other frustum planes.
-
isPointBehindLineOrigin
public boolean isPointBehindLineOrigin(Vec4 point)
Determine if a point is behind theLine
's origin.- Parameters:
point
- The point to test.- Returns:
- true if
point
is behind thisLine
's origin, false otherwise.
-
nearestIntersectionPoint
public Vec4 nearestIntersectionPoint(Intersection[] intersections)
-
-