com.jme.math
Class Plane

java.lang.Object
  extended by com.jme.math.Plane
All Implemented Interfaces:
Savable, java.io.Serializable, java.lang.Cloneable

public class Plane
extends java.lang.Object
implements java.io.Serializable, Savable, java.lang.Cloneable

A plane in 3D space.

The plane is defined by a vector, N which is normal to the plane; and a constant, C, representing the distance of the plane from the origin. The plane can be represented by the equation C = N∙p where p

is a point on the plane.

Version:
$Revision: 4134 $, $Date: 2009-03-19 21:04:38 +0000 (Thu, 19 Mar 2009) $
Author:
Mark Powell, Joshua Slack
See Also:
Serialized Form

Nested Class Summary
static class Plane.Side
           
 
Field Summary
 float constant
          Constant of the plane.
 Vector3f normal
          Vector normal to the plane.
 
Constructor Summary
Plane()
          Constructor instantiates a new Plane object.
Plane(Vector3f normal, float constant)
          Constructor instantiates a new Plane object.
 
Method Summary
 Plane clone()
           
 java.lang.Class<? extends Plane> getClassTag()
           
 float getConstant()
          getConstant returns the constant of the plane.
 Vector3f getNormal()
          getNormal retrieves the normal of the plane.
 float pseudoDistance(Vector3f point)
          pseudoDistance calculates the distance from this plane to a provided point.
 void read(JMEImporter e)
           
 void setConstant(float constant)
          setConstant sets the constant value that helps define the plane.
 void setNormal(Vector3f normal)
          setNormal sets the normal of the plane.
 void setPlanePoints(Triangle 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 thta represents the string representation of this plane.
 Plane.Side whichSide(Vector3f p)
          Determine on which side of this plane the point p lies.
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

normal

public Vector3f normal
Vector normal to the plane.


constant

public float constant
Constant of the plane. See formula in class definition.

Constructor Detail

Plane

public Plane()
Constructor instantiates a new Plane object. This is the default object and contains a normal of (0,0,0) and a constant of 0.


Plane

public Plane(Vector3f normal,
             float constant)
Constructor instantiates a new Plane object. The normal and constant values are set at creation.

Parameters:
normal - the normal of the plane.
constant - the constant of the plane.
Method Detail

setNormal

public void setNormal(Vector3f normal)
setNormal sets the normal of the plane.

Parameters:
normal - the new normal of the plane.

getNormal

public Vector3f getNormal()
getNormal retrieves the normal of the plane.

Returns:
the normal of the plane.

setConstant

public void setConstant(float constant)
setConstant sets the constant value that helps define the plane.

Parameters:
constant - the new constant value.

getConstant

public float getConstant()
getConstant returns the constant of the plane.

Returns:
the constant of the plane.

pseudoDistance

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.

Parameters:
point - the point to check.
Returns:
the signed distance from the plane to a point.

whichSide

public Plane.Side whichSide(Vector3f p)
Determine on which side of this plane the point p lies.

Parameters:
p - the point to check.
Returns:
the side at which the point lies.

setPlanePoints

public void setPlanePoints(Triangle t)
Initialize this plane using the three points of the given triangle.

Parameters:
t - the triangle

setPlanePoints

public void setPlanePoints(Vector3f v1,
                           Vector3f v2,
                           Vector3f v3)
Initialize the Plane using the given 3 points as coplanar.

Parameters:
v1 - the first point
v2 - the second point
v3 - the third point

toString

public java.lang.String toString()
toString returns a string thta represents the string representation of this plane. It represents the normal as a Vector3f object, so the format is the following: com.jme.math.Plane [Normal: org.jme.math.Vector3f [X=XX.XXXX, Y=YY.YYYY, Z=ZZ.ZZZZ] - Constant: CC.CCCCC]

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this plane.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class<? extends Plane> getClassTag()
Specified by:
getClassTag in interface Savable

clone

public Plane clone()
Overrides:
clone in class java.lang.Object