Package toxi.geom

Class Plane

All Implemented Interfaces:
Comparable<ReadonlyVec3D>, ReadonlyVec3D, Shape3D

public class Plane extends Vec3D implements Shape3D
Class to describe and work with infinite generic 3D planes. Useful for intersection problems and classifying points.
  • Field Details

    • XY

      public static final Plane XY
    • XZ

      public static final Plane XZ
    • YZ

      public static final Plane YZ
    • normal

      public Vec3D normal
  • Constructor Details

  • Method Details

    • classifyPoint

      public Plane.Classifier classifyPoint(ReadonlyVec3D p, float tolerance)
      Classifies the relative position of the given point to the plane using the given tolerance.
      Returns:
      One of the 3 classification types: FRONT, BACK, ON_PLANE
    • containsPoint

      public boolean containsPoint(ReadonlyVec3D p)
      Description copied from interface: Shape3D
      Checks if the point is within the given shape/volume.
      Specified by:
      containsPoint in interface Shape3D
      Returns:
      true, if inside
    • getDCoeff

      public float getDCoeff()
    • getDistanceToPoint

      public float getDistanceToPoint(Vec3D p)
      Calculates distance from the plane to point P.
      Parameters:
      p -
      Returns:
      distance
    • getIntersectionWithRay

      public ReadonlyVec3D 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
    • getProjectedPoint

      public Vec3D getProjectedPoint(Vec3D p)
    • 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.
    • intersectsPlane

      public Ray3D intersectsPlane(Plane plane)
      Computes the intersection ray between this plane and the given one. If the planes are parallel or coincident the method returns null. If the planes are intersecting, the returned Ray3D will start at a point lying on both planes and point along the infinite intersection line between them. Code ported from: http://forums.create.msdn.com/forums/p/39074/234178.aspx#234178
      Parameters:
      plane - intersection partner
      Returns:
      intersection ray or null
    • toMesh

      public Mesh3D 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
    • toMesh

      public Mesh3D toMesh(Mesh3D mesh, float size)
    • toString

      public String toString()
      Overrides:
      toString in class Vec3D