public class Plane extends java.lang.Object implements Savable, java.lang.Cloneable, java.io.Serializable
Plane
defines a plane where Normal dot (x,y,z) = Constant.
This provides methods for calculating a "distance" of a point from this
plane. The distance is pseudo due to the fact that it can be negative if the
point is on the non-normal side of the plane.Modifier and Type | Class and Description |
---|---|
static class |
Plane.Side
Describe the relationship between a point and a plane.
|
Modifier and Type | Field and Description |
---|---|
protected float |
constant
Constant of the plane.
|
protected Vector3f |
normal
Vector normal to the plane.
|
Constructor and Description |
---|
Plane()
Constructor instantiates a new
Plane object. |
Plane(Vector3f normal,
float constant)
Constructor instantiates a new
Plane object. |
Plane(Vector3f normal,
Vector3f displacement)
Constructor instantiates a new
Plane object. |
Modifier and Type | Method and Description |
---|---|
Plane |
clone()
Create a copy of this plane.
|
Vector3f |
getClosestPoint(Vector3f point)
Find the point in this plane that's nearest to the specified point.
|
Vector3f |
getClosestPoint(Vector3f point,
Vector3f store)
Find the point in this plane that's nearest to the specified point.
|
float |
getConstant()
getConstant returns the constant of the plane. |
Vector3f |
getNormal()
getNormal retrieves the normal of the plane. |
boolean |
isOnPlane(Vector3f point) |
float |
pseudoDistance(Vector3f point)
pseudoDistance calculates the distance from this plane to
a provided point. |
void |
read(JmeImporter e)
De-serialize this plane from the specified importer, for example when
loading from a J3O file.
|
Vector3f |
reflect(Vector3f point,
Vector3f store)
Reflect the specified point in this plane.
|
void |
setConstant(float constant)
setConstant sets the constant value that helps define the
plane. |
void |
setNormal(float x,
float y,
float z)
setNormal sets the normal of the plane. |
void |
setNormal(Vector3f normal)
setNormal sets the normal of the plane. |
void |
setOriginNormal(Vector3f origin,
Vector3f normal)
Initialize this plane using a point of origin and a normal.
|
void |
setPlanePoints(AbstractTriangle t)
Initialize this plane using the three points of the given triangle.
|
void |
setPlanePoints(Vector3f v1,
Vector3f v2,
Vector3f v3)
Initialize the Plane using the given 3 points as coplanar.
|
java.lang.String |
toString()
toString returns a string representation of this plane. |
Plane.Side |
whichSide(Vector3f point)
whichSide returns the side at which a point lies on the
plane. |
void |
write(JmeExporter e)
Serialize this plane to the specified exporter, for example when
saving to a J3O file.
|
protected Vector3f normal
protected float constant
public Plane()
Plane
object. This is the
default object and contains a normal of (0,0,0) and a constant of 0.public Plane(Vector3f normal, float constant)
Plane
object. The normal
and constant values are set at creation.normal
- the normal of the plane.constant
- the constant of the plane.public void setNormal(Vector3f normal)
setNormal
sets the normal of the plane.normal
- the new normal of the plane.public void setNormal(float x, float y, float z)
setNormal
sets the normal of the plane.x
- the desired X component for the normal vectory
- the desired Y component for the normal vectorz
- the desired Z component for the normal vectorpublic Vector3f getNormal()
getNormal
retrieves the normal of the plane.public void setConstant(float constant)
setConstant
sets the constant value that helps define the
plane.constant
- the new constant value.public float getConstant()
getConstant
returns the constant of the plane.public Vector3f getClosestPoint(Vector3f point, Vector3f store)
point
- location vector of the input point (not null, unaffected)store
- storage for the result (not null, modififed)public Vector3f getClosestPoint(Vector3f point)
point
- location vector of the input point (not null, unaffected)public Vector3f reflect(Vector3f point, Vector3f store)
point
- location vector of the input point (not null, unaffected)store
- storage for the result (modififed if not null)public float pseudoDistance(Vector3f point)
pseudoDistance
calculates the distance from this plane to
a provided point. If the point is on the negative side of the plane the
distance returned is negative, otherwise it is positive. If the point is
on the plane, it is zero.point
- the point to check.public Plane.Side whichSide(Vector3f point)
whichSide
returns the side at which a point lies on the
plane. The positive values returned are: NEGATIVE_SIDE, POSITIVE_SIDE and
NO_SIDE.point
- the point to check.public boolean isOnPlane(Vector3f point)
public void setPlanePoints(AbstractTriangle t)
t
- the trianglepublic void setOriginNormal(Vector3f origin, Vector3f normal)
origin
- the desired origin location (not null, unaffected)normal
- the desired normal vector (not null, unaffected)public void setPlanePoints(Vector3f v1, Vector3f v2, Vector3f v3)
v1
- the first pointv2
- the second pointv3
- the third pointpublic java.lang.String toString()
toString
returns a string representation of this plane.
It represents the normal as a Vector3f
, so the format is:
Plane [Normal: (X.XXXX, Y.YYYY, Z.ZZZZ) - Constant: C.CCCC]toString
in class java.lang.Object
public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public Plane clone()
clone
in class java.lang.Object