Package arc.math.geom

Class Plane

java.lang.Object
arc.math.geom.Plane

public class Plane extends Object
A plane defined via a unit length normal and the distance from the origin, as you learned in your math class.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enum specifying on which side a point lies respective to the plane and it's normal.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
     
    final Vec3
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new plane with all values set to 0
    Plane(Vec3 normal, float d)
    Constructs a new plane based on the normal and distance to the origin.
    Plane(Vec3 normal, Vec3 point)
    Constructs a new plane based on the normal and a point on the plane.
    Plane(Vec3 point1, Vec3 point2, Vec3 point3)
    Constructs a new plane out of the three given points that are considered to be on the plane.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    distance(Vec3 point)
    Calculates the shortest signed distance between the plane and the given point.
    float
     
     
    boolean
    isFrontFacing(Vec3 direction)
    Returns whether the plane is facing the direction vector.
    Projects the supplied vector onto this plane.
    void
    set(float nx, float ny, float nz, float d)
    Sets the plane normal and distance
    void
    set(float pointX, float pointY, float pointZ, float norX, float norY, float norZ)
     
    void
    set(Plane plane)
    Sets this plane from the given plane
    void
    set(Vec3 point, Vec3 normal)
    Sets the plane to the given point and normal.
    void
    set(Vec3 point1, Vec3 point2, Vec3 point3)
    Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane.
    testPoint(float x, float y, float z)
    Returns on which side the given point lies relative to the plane and its normal.
    testPoint(Vec3 point)
    Returns on which side the given point lies relative to the plane and its normal.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • normal

      public final Vec3 normal
    • d

      public float d
  • Constructor Details

    • Plane

      public Plane()
      Constructs a new plane with all values set to 0
    • Plane

      public Plane(Vec3 normal, float d)
      Constructs a new plane based on the normal and distance to the origin.
      Parameters:
      normal - The plane normal
      d - The distance to the origin
    • Plane

      public Plane(Vec3 normal, Vec3 point)
      Constructs a new plane based on the normal and a point on the plane.
      Parameters:
      normal - The normal
      point - The point on the plane
    • Plane

      public Plane(Vec3 point1, Vec3 point2, Vec3 point3)
      Constructs a new plane out of the three given points that are considered to be on the plane. The normal is calculated via a cross product between (point1-point2)x(point2-point3)
      Parameters:
      point1 - The first point
      point2 - The second point
      point3 - The third point
  • Method Details

    • set

      public void set(Vec3 point1, Vec3 point2, Vec3 point3)
      Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane. The normal is calculated via a cross product between (point1-point2)x(point2-point3)
    • set

      public void set(float nx, float ny, float nz, float d)
      Sets the plane normal and distance
      Parameters:
      nx - normal x-component
      ny - normal y-component
      nz - normal z-component
      d - distance to origin
    • project

      public Vec3 project(Vec3 v)
      Projects the supplied vector onto this plane.
      Parameters:
      v - the vector to project onto this plane.
    • distance

      public float distance(Vec3 point)
      Calculates the shortest signed distance between the plane and the given point.
      Parameters:
      point - The point
      Returns:
      the shortest signed distance between the plane and the point
    • testPoint

      public Plane.PlaneSide testPoint(Vec3 point)
      Returns on which side the given point lies relative to the plane and its normal. PlaneSide.Front refers to the side the plane normal points to.
      Parameters:
      point - The point
      Returns:
      The side the point lies relative to the plane
    • testPoint

      public Plane.PlaneSide testPoint(float x, float y, float z)
      Returns on which side the given point lies relative to the plane and its normal. PlaneSide.Front refers to the side the plane normal points to.
      Returns:
      The side the point lies relative to the plane
    • isFrontFacing

      public boolean isFrontFacing(Vec3 direction)
      Returns whether the plane is facing the direction vector. Think of the direction vector as the direction a camera looks in. This method will return true if the front side of the plane determined by its normal faces the camera.
      Parameters:
      direction - the direction
      Returns:
      whether the plane is front facing
    • getNormal

      public Vec3 getNormal()
      Returns:
      The normal
    • getD

      public float getD()
      Returns:
      The distance to the origin
    • set

      public void set(Vec3 point, Vec3 normal)
      Sets the plane to the given point and normal.
      Parameters:
      point - the point on the plane
      normal - the normal of the plane
    • set

      public void set(float pointX, float pointY, float pointZ, float norX, float norY, float norZ)
    • set

      public void set(Plane plane)
      Sets this plane from the given plane
      Parameters:
      plane - the plane
    • toString

      public String toString()
      Overrides:
      toString in class Object