Package gov.nasa.worldwind.geom
Class Line
- java.lang.Object
-
- gov.nasa.worldwind.geom.Line
-
public class Line extends java.lang.Object
Represents a line in Cartesian coordinates.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
hashCode()
Vec3
pointAt(double distance, Vec3 result)
Computes a Cartesian point a specified distance along this line.Line
set(Vec3 origin, Vec3 direction)
Sets this line to a specified origin and direction.Line
setToSegment(Vec3 pointA, Vec3 pointB)
Sets this line to the specified segment.java.lang.String
toString()
boolean
triStripIntersection(float[] points, int stride, short[] elements, int count, Vec3 result)
Computes the first intersection of a triangle strip with this line.
-
-
-
Constructor Detail
-
Line
public Line()
Constructs a line with origin and direction both zero.
-
Line
public Line(Vec3 origin, Vec3 direction)
Constructs a line with a specified origin and direction.- Parameters:
origin
- the line's origindirection
- the line's direction- Throws:
java.lang.IllegalArgumentException
- If either the origin or the direction are null
-
Line
public Line(Line line)
Constructs a line with the origin and direction from a specified line.- Parameters:
line
- the line specifying origin and direction- Throws:
java.lang.IllegalArgumentException
- If the line is null
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
set
public Line set(Vec3 origin, Vec3 direction)
Sets this line to a specified origin and direction.- Parameters:
origin
- the line's new origindirection
- the line's new direction- Returns:
- this line, set to the new origin and direction
- Throws:
java.lang.IllegalArgumentException
- If either the origin or the direction are null
-
setToSegment
public Line setToSegment(Vec3 pointA, Vec3 pointB)
Sets this line to the specified segment. This line has its origin at the first endpoint and its direction extending from the first endpoint to the second.- Parameters:
pointA
- the segment's first endpointpointB
- the segment's second endpoint- Returns:
- this line, set to the specified segment
- Throws:
java.lang.IllegalArgumentException
- If either endpoint is null
-
pointAt
public Vec3 pointAt(double distance, Vec3 result)
Computes a Cartesian point a specified distance along this line.- Parameters:
distance
- The distance from this line's origin at which to compute the point.result
- A pre-allocatedVec3
instance in which to return the computed point.- Returns:
- The specified result argument containing the computed point.
- Throws:
java.lang.IllegalArgumentException
- If the specified result argument is null or undefined.
-
triStripIntersection
public boolean triStripIntersection(float[] points, int stride, short[] elements, int count, Vec3 result)
Computes the first intersection of a triangle strip with this line. This line is interpreted as a ray; intersection points behind the line's origin are ignored.
The triangle strip is specified by a list of vertex points and a list of elements indicating the triangle strip tessellation of those vertices. The triangle strip elements are interpreted in the same manner as OpenGL, where each index indicates a vertex position rather than an actual index into the points array (e.g. a triangle strip index of 1 indicates the XYZ tuple starting at array index 3).- Parameters:
points
- an array of points containing XYZ tuplesstride
- the number of coordinates between the first coordinate of adjacent points - must be at least 3elements
- an array of indices into the points defining the triangle strip organizationcount
- the number of indices to considerresult
- a pre-allocated Vec3 in which to return the nearest intersection point, if any- Returns:
- true if this line intersects the triangle strip, otherwise false
- Throws:
java.lang.IllegalArgumentException
- If either array is null or empty, if the stride is less than 3, if the count is less than 0, or if the result argument is null
-
-