public final class Plane
extends java.lang.Object
Plane
in Cartesian coordinates, defined by a normal vector to the plane and a signed scalar
value proportional to the distance of the plane from the origin. The sign of the value is relative to the direction
of the plane normal.Constructor and Description |
---|
Plane(double nx,
double ny,
double nz,
double d)
Constructs a plane from four values giving the plane normal vector and distance.
|
Plane(Vec4 vec)
Constructs a plane from a 4-D vector giving the plane normal vector and distance.
|
Modifier and Type | Method and Description |
---|---|
Vec4[] |
clip(Vec4 pa,
Vec4 pb)
Clip a line segment to this plane.
|
double |
distanceTo(Vec4 p) |
double |
dot(Vec4 p)
Calculates the 4-D dot product of this plane with a vector.
|
boolean |
equals(java.lang.Object o) |
static Plane |
fromPoints(Vec4 pa,
Vec4 pb,
Vec4 pc)
Returns the plane that passes through the specified three points.
|
double |
getDistance()
Returns the plane distance.
|
Vec4 |
getNormal()
Returns the plane's normal vector.
|
Vec4 |
getVector()
Returns a 4-D vector holding the plane's normal and distance.
|
int |
hashCode() |
Vec4 |
intersect(Line line)
Determine the intersection point of a line with this plane.
|
static Vec4 |
intersect(Plane pa,
Plane pb,
Plane pc)
Compute the intersection of three planes.
|
Vec4 |
intersect(Vec4 pa,
Vec4 pb)
Test a line segment for intersection with this plane.
|
double |
intersectDistance(Line line)
Determine the parametric point of intersection of a line with this plane.
|
Plane |
normalize()
Returns a normalized version of this plane.
|
int |
onSameSide(Vec4[] pts)
Determines whether multiple points are on the same side of a plane.
|
int |
onSameSide(Vec4 pa,
Vec4 pb)
Determines whether two points are on the same side of a plane.
|
java.lang.String |
toString() |
public Plane(double nx, double ny, double nz, double d)
nx
- the X component of the plane normal vector.ny
- the Y component of the plane normal vector.nz
- the Z component of the plane normal vector.d
- the plane distance.java.lang.IllegalArgumentException
- if the normal vector components define the zero vector (all values are zero).public Plane(Vec4 vec)
vec
- a 4-D vector indicating the plane's normal vector and distance. The normal need not be unit length.java.lang.IllegalArgumentException
- if the vector is null.public Vec4[] clip(Vec4 pa, Vec4 pb)
pa
- the first point of the segment.pb
- the second point of the segment.java.lang.IllegalArgumentException
- if either input point is null.public double distanceTo(Vec4 p)
public final double dot(Vec4 p)
p
- the vector.java.lang.IllegalArgumentException
- if the vector is null.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public static Plane fromPoints(Vec4 pa, Vec4 pb, Vec4 pc)
pb
to pa and pc
to pa, respectively. The
returned plane is undefined if any of the specified points are colinear.pa
- the first point.pb
- the second point.pc
- the third point.Plane
passing through the specified points.java.lang.IllegalArgumentException
- if pa
, pb
, or pc
is null
.public final double getDistance()
public final Vec4 getNormal()
public final Vec4 getVector()
public int hashCode()
hashCode
in class java.lang.Object
public Vec4 intersect(Line line)
line
- the line to intersect.java.lang.IllegalArgumentException
- if the line is null.public static Vec4 intersect(Plane pa, Plane pb, Plane pc)
pa
- the first plane.pb
- the second plane.pc
- the third plane.java.lang.IllegalArgumentException
- if any of the planes are null.public Vec4 intersect(Vec4 pa, Vec4 pb)
pa
- the first point of the line segment.pb
- the second point of the line segment.Vec4.INFINITY
coincident with the plane.java.lang.IllegalArgumentException
- if either input point is null.public double intersectDistance(Line line)
line
- the line to testDouble.NaN
is
returned if the line does not intersect the plane. Double.POSITIVE_INFINITY
is returned if the
line is coincident with the plane.java.lang.IllegalArgumentException
- if the line is null.public final Plane normalize()
public int onSameSide(Vec4[] pts)
pts
- the array of points.java.lang.IllegalArgumentException
- if the points array is null or any point within it is null.public int onSameSide(Vec4 pa, Vec4 pb)
pa
- the first point.pb
- the second point.java.lang.IllegalArgumentException
- if either point is null.public final java.lang.String toString()
toString
in class java.lang.Object