Class PlaneDouble

java.lang.Object
gaiasky.util.math.PlaneDouble
All Implemented Interfaces:
Serializable

public class PlaneDouble extends Object implements Serializable
See Also:
  • 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
    double
     
    final Vector3d
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new plane with all values set to 0
    PlaneDouble(Vector3d normal, double d)
    Constructs a new plane based on the normal and distance to the origin.
    PlaneDouble(Vector3d normal, Vector3d point)
    Constructs a new plane based on the normal and a point on the plane.
    PlaneDouble(Vector3d point1, Vector3d point2, Vector3d 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
    double
    Calculates the shortest signed distance between the plane and the given point.
    double
     
     
    boolean
    Returns whether the plane is facing the direction vector.
    void
    set(double nx, double ny, double nz, double d)
    Sets the plane normal and distance
    void
    set(double pointX, double pointY, double pointZ, double norX, double norY, double norZ)
     
    void
    Sets this plane from the given plane
    void
    set(Vector3d point, Vector3d normal)
    Sets the plane to the given point and normal.
    void
    set(Vector3d point1, Vector3d point2, Vector3d 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(double x, double y, double z)
    Returns on which side the given point lies relative to the plane and its normal.
    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 Vector3d normal
    • d

      public double d
  • Constructor Details

    • PlaneDouble

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

      public PlaneDouble(Vector3d normal, double 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
    • PlaneDouble

      public PlaneDouble(Vector3d normal, Vector3d 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
    • PlaneDouble

      public PlaneDouble(Vector3d point1, Vector3d point2, Vector3d 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(Vector3d point1, Vector3d point2, Vector3d 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)
      Parameters:
      point1 -
      point2 -
      point3 -
    • set

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

      public double distance(Vector3d 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 PlaneDouble.PlaneSide testPoint(Vector3d 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 PlaneDouble.PlaneSide testPoint(double x, double y, double 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.
      Parameters:
      x -
      y -
      z -
      Returns:
      The side the point lies relative to the plane
    • isFrontFacing

      public boolean isFrontFacing(Vector3d 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 Vector3d getNormal()
      Returns:
      The normal
    • getD

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

      public void set(Vector3d point, Vector3d 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(double pointX, double pointY, double pointZ, double norX, double norY, double norZ)
    • set

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

      public String toString()
      Overrides:
      toString in class Object