com.threerings.math
Class Plane

java.lang.Object
  extended by com.threerings.math.Plane
All Implemented Interfaces:
Encodable, Exportable, com.threerings.io.Streamable

public class Plane
extends Object
implements Encodable, com.threerings.io.Streamable

A plane consisting of a unit normal and a constant. All points on the plane satisfy the equation Ax + By + Cz + D = 0, where (A, B, C) is the plane normal and D is the constant.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Field Summary
 float constant
          The plane constant.
static Plane XY_PLANE
          The X/Y plane.
static Plane XZ_PLANE
          The X/Z plane.
static Plane YZ_PLANE
          The Y/Z plane.
 
Constructor Summary
Plane()
          Creates an empty (invalid) plane.
Plane(float[] values)
          Creates a plane with the specified parameters.
Plane(float a, float b, float c, float d)
          Creates a plane with the specified parameters.
Plane(Plane other)
          Copy constructor.
Plane(Vector3f normal, float constant)
          Creates a plane from the specified normal and constant.
 
Method Summary
 void decodeFromStream(DataInputStream in)
          Initializes this object with data read from the specified stream.
 void decodeFromString(String string)
          Initializes this object with the contents of the specified string.
 void encodeToStream(DataOutputStream out)
          Encodes this object to the specified stream.
 String encodeToString()
          Returns a string representation of this object.
 boolean equals(Object other)
           
 Plane fromPointNormal(Vector3f pt, Vector3f normal)
          Sets this plane based on a point on the plane and the plane normal.
 Plane fromPoints(Vector3f p1, Vector3f p2, Vector3f p3)
          Sets this plane based on the three points provided.
 DoubleBuffer get(DoubleBuffer buf)
          Stores the contents of this plane into the specified buffer.
 float getDistance(Ray3D ray)
          Computes the signed distance to this plane along the specified ray.
 float getDistance(Vector3f pt)
          Computes and returns the signed distance from the plane to the specified point.
 boolean getIntersection(Ray3D ray, Vector3f result)
          Computes the intersection of the supplied ray with this plane, placing the result in the given vector (if the ray intersects).
 Vector3f getNormal()
          Returns a reference to the plane normal.
 int hashCode()
           
 Plane negate()
          Negates this plane.
 Plane negate(Plane result)
          Negates this plane, placing the result in the object provided.
 Plane negateLocal()
          Negates this plane in-place.
 Plane set(float[] values)
          Sets the parameters of the plane.
 Plane set(float a, float b, float c, float d)
          Sets the parameters of the plane.
 Plane set(Plane other)
          Copies the parameters of another plane.
 Plane set(Vector3f normal, float constant)
          Sets the parameters of the plane.
 Plane transform(Transform3D transform)
          Transforms this plane by the specified transformation.
 Plane transform(Transform3D transform, Plane result)
          Transforms this plane by the specified transformation, placing the result in the object provided.
 Plane transformLocal(Transform3D transform)
          Transforms this plane in-place by the specified transformation.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XY_PLANE

public static final Plane XY_PLANE
The X/Y plane.


XZ_PLANE

public static final Plane XZ_PLANE
The X/Z plane.


YZ_PLANE

public static final Plane YZ_PLANE
The Y/Z plane.


constant

public float constant
The plane constant.

Constructor Detail

Plane

public Plane(Vector3f normal,
             float constant)
Creates a plane from the specified normal and constant.


Plane

public Plane(float[] values)
Creates a plane with the specified parameters.


Plane

public Plane(float a,
             float b,
             float c,
             float d)
Creates a plane with the specified parameters.


Plane

public Plane(Plane other)
Copy constructor.


Plane

public Plane()
Creates an empty (invalid) plane.

Method Detail

getNormal

public Vector3f getNormal()
Returns a reference to the plane normal.


fromPoints

public Plane fromPoints(Vector3f p1,
                        Vector3f p2,
                        Vector3f p3)
Sets this plane based on the three points provided.

Returns:
a reference to the plane (for chaining).

fromPointNormal

public Plane fromPointNormal(Vector3f pt,
                             Vector3f normal)
Sets this plane based on a point on the plane and the plane normal.

Returns:
a reference to the plane (for chaining).

set

public Plane set(Plane other)
Copies the parameters of another plane.

Returns:
a reference to this plane (for chaining).

set

public Plane set(Vector3f normal,
                 float constant)
Sets the parameters of the plane.

Returns:
a reference to this plane (for chaining).

set

public Plane set(float[] values)
Sets the parameters of the plane.

Returns:
a reference to this plane (for chaining).

set

public Plane set(float a,
                 float b,
                 float c,
                 float d)
Sets the parameters of the plane.

Returns:
a reference to this plane (for chaining).

transformLocal

public Plane transformLocal(Transform3D transform)
Transforms this plane in-place by the specified transformation.

Returns:
a reference to this plane, for chaining.

transform

public Plane transform(Transform3D transform)
Transforms this plane by the specified transformation.

Returns:
a new plane containing the result.

transform

public Plane transform(Transform3D transform,
                       Plane result)
Transforms this plane by the specified transformation, placing the result in the object provided.

Returns:
a reference to the result plane, for chaining.

negateLocal

public Plane negateLocal()
Negates this plane in-place.

Returns:
a reference to this plane, for chaining.

negate

public Plane negate()
Negates this plane.

Returns:
a new plane containing the result.

negate

public Plane negate(Plane result)
Negates this plane, placing the result in the object provided.

Returns:
a reference to the result, for chaining.

getIntersection

public boolean getIntersection(Ray3D ray,
                               Vector3f result)
Computes the intersection of the supplied ray with this plane, placing the result in the given vector (if the ray intersects).

Returns:
true if the ray intersects the plane (in which case the result will contain the point of intersection), false if not.

getDistance

public float getDistance(Ray3D ray)
Computes the signed distance to this plane along the specified ray.

Returns:
the signed distance, or {Float#NaN} if the ray runs parallel to the plane.

getDistance

public float getDistance(Vector3f pt)
Computes and returns the signed distance from the plane to the specified point.


get

public DoubleBuffer get(DoubleBuffer buf)
Stores the contents of this plane into the specified buffer.


encodeToString

public String encodeToString()
Description copied from interface: Encodable
Returns a string representation of this object.

Specified by:
encodeToString in interface Encodable

decodeFromString

public void decodeFromString(String string)
                      throws Exception
Description copied from interface: Encodable
Initializes this object with the contents of the specified string.

Specified by:
decodeFromString in interface Encodable
Throws:
Exception

encodeToStream

public void encodeToStream(DataOutputStream out)
                    throws IOException
Description copied from interface: Encodable
Encodes this object to the specified stream.

Specified by:
encodeToStream in interface Encodable
Throws:
IOException

decodeFromStream

public void decodeFromStream(DataInputStream in)
                      throws IOException
Description copied from interface: Encodable
Initializes this object with data read from the specified stream.

Specified by:
decodeFromStream in interface Encodable
Throws:
IOException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object


Copyright © 2011. All Rights Reserved.