toxi.geom
Class Plane

java.lang.Object
  extended by toxi.geom.Vec3D
      extended by toxi.geom.Plane
All Implemented Interfaces:
java.lang.Comparable<Vec3D>

public class Plane
extends Vec3D

Class to describe and work with infinite generic 3D planes. Useful for intersection problems and classifying points.

Author:
Karsten Schmidt

Nested Class Summary
 
Nested classes/interfaces inherited from class toxi.geom.Vec3D
Vec3D.Axis
 
Field Summary
 Vec3D normal
           
static int ON_PLANE
          Classifier constant for classifyPoint(Vec3D)
static int PLANE_BACK
          Classifier constant for classifyPoint(Vec3D)
static int PLANE_FRONT
          Classifier constant for classifyPoint(Vec3D)
static Plane XY
           
static Plane XZ
           
static Plane YZ
           
 
Fields inherited from class toxi.geom.Vec3D
MAX_VALUE, MIN_VALUE, x, X_AXIS, y, Y_AXIS, z, Z_AXIS, ZERO
 
Constructor Summary
Plane()
           
Plane(Triangle t)
           
Plane(Vec3D origin, Vec3D norm)
           
 
Method Summary
 int classifyPoint(Vec3D p)
          Classifies the relative position of the given point to the plane.
 float getDistanceToPoint(Vec3D p)
          Calculates distance from the plane to point P.
 Vec3D getIntersectionWithRay(Ray3D r)
          Calculates the intersection point between plane and ray (line).
 float intersectRayDistance(Ray3D ray)
          Calculates the distance of the vector to the given plane in the specified direction.
 TriangleMesh toMesh(float size)
          Creates a TriangleMesh representation of the plane as a finite, squared quad of the requested size, centred around the current plane point.
 java.lang.String toString()
           
 
Methods inherited from class toxi.geom.Vec3D
abs, add, add, addSelf, addSelf, angleBetween, angleBetween, clear, closestPointOnLine, compareTo, constrain, constrain, copy, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getNormalized, getNormalizedTo, getReciprocal, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getSignum, hashCode, headingXY, headingXZ, headingYZ, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isZeroVector, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, rotateAroundAxis, rotateX, rotateY, rotateZ, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, set, set, setComponent, setXY, signum, sub, sub, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, toArray, toCartesian, toSpherical
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XY

public static final Plane XY

XZ

public static final Plane XZ

YZ

public static final Plane YZ

PLANE_FRONT

public static final int PLANE_FRONT
Classifier constant for classifyPoint(Vec3D)

See Also:
Constant Field Values

PLANE_BACK

public static final int PLANE_BACK
Classifier constant for classifyPoint(Vec3D)

See Also:
Constant Field Values

ON_PLANE

public static final int ON_PLANE
Classifier constant for classifyPoint(Vec3D)

See Also:
Constant Field Values

normal

public Vec3D normal
Constructor Detail

Plane

public Plane()

Plane

public Plane(Triangle t)

Plane

public Plane(Vec3D origin,
             Vec3D norm)
Method Detail

classifyPoint

public int classifyPoint(Vec3D p)
Classifies the relative position of the given point to the plane.

Returns:
One of the 3 integer classification codes: PLANE_FRONT, PLANE_BACK, ON_PLANE

getDistanceToPoint

public float getDistanceToPoint(Vec3D p)
Calculates distance from the plane to point P.

Parameters:
p -
Returns:
distance

getIntersectionWithRay

public Vec3D getIntersectionWithRay(Ray3D r)
Calculates the intersection point between plane and ray (line).

Parameters:
r -
Returns:
intersection point or null if ray doesn't intersect plane

intersectRayDistance

public float intersectRayDistance(Ray3D ray)
Calculates the distance of the vector to the given plane in the specified direction. A plane is specified by a 3D point and a normal vector perpendicular to the plane. Normalized directional vectors expected (for rayDir and planeNormal).

Parameters:
ray - intersection ray
Returns:
distance to plane in world units, -1 if no intersection.

toMesh

public TriangleMesh toMesh(float size)
Creates a TriangleMesh representation of the plane as a finite, squared quad of the requested size, centred around the current plane point.

Parameters:
size - desired edge length
Returns:
mesh

toString

public java.lang.String toString()
Overrides:
toString in class Vec3D