Record Class NormalPlane

java.lang.Object
java.lang.Record
com.j3d.engine.math.plane.NormalPlane
Record Components:
origin - The point on the plane
normal - The normal vector pointing outwards from the plane

public record NormalPlane(Vector3 origin, Vector3 normal) extends Record
A plane is defined by a normal vector and a point on the plane (origin).
Author:
Lehlogonolo Poole
  • Field Details

    • origin

      private final Vector3 origin
      The field for the origin record component.
    • normal

      private final Vector3 normal
      The field for the normal record component.
    • EPSILON

      public static final double EPSILON
      See Also:
  • Constructor Details

    • NormalPlane

      public NormalPlane(Vector3 origin, Vector3 normal)
      Creates an instance of a NormalPlane record class.
      Parameters:
      origin - the value for the origin record component
      normal - the value for the normal record component
  • Method Details

    • toAxisPlane

      public AxisPlane toAxisPlane()
      Converts this NormalPlane into an AxisPlane. This method calculates two orthogonal vectors (x and y) that lie within the plane, forming a local coordinate system for the plane.
      Returns:
      A new AxisPlane representing the same plane.
    • onPlane

      public boolean onPlane(Vector3 pos)
      Checks if a given 3D point lies on this plane.
      Parameters:
      pos - The 3D point to check.
      Returns:
      true if the point is on the plane (within a small epsilon tolerance), false otherwise.
    • pair

      public SamePair<NormalPlane> pair()
      Returns a SamePair containing two references to this NormalPlane. This can be useful in contexts where a pair of identical objects is required.
      Returns:
      A SamePair with both elements being this NormalPlane.
    • from

      public static NormalPlane from(Vector3 A, Vector3 B, Vector3 C)
      Creates a NormalPlane from three points in 3D space. The normal vector is calculated using the cross product of two vectors formed by the points, and is then normalised. The origin of the plane is set to point A.
      Parameters:
      A - The first point.
      B - The second point.
      C - The third point.
      Returns:
      A new NormalPlane defined by the three points.
    • from

      public static NormalPlane from(GTri tri)
      Creates a NormalPlane from a GTri (triangle). The origin of the plane is set to the pivot point of the first leg's first point of the triangle, and the normal vector is taken directly from the triangle's normal.
      Parameters:
      tri - The GTri from which to create the NormalPlane.
      Returns:
      A new NormalPlane defined by the triangle.
    • XZ

      public static NormalPlane XZ(Vector3 origin)
      Creates a NormalPlane that is parallel to the XZ-plane. The normal vector is Vector3.Y (pointing along the positive Y-axis).
      Parameters:
      origin - The origin point on the plane.
      Returns:
      A new NormalPlane parallel to the XZ-plane.
    • XY

      public static NormalPlane XY(Vector3 origin)
      Creates a NormalPlane that is parallel to the XY-plane. The normal vector is Vector3.Z (pointing along the positive Z-axis).
      Parameters:
      origin - The origin point on the plane.
      Returns:
      A new NormalPlane parallel to the XY-plane.
    • ZY

      public static NormalPlane ZY(Vector3 origin)
      Creates a NormalPlane that is parallel to the ZY-plane (or YZ-plane). The normal vector is Vector3.X (pointing along the positive X-axis).
      Parameters:
      origin - The origin point on the plane.
      Returns:
      A new NormalPlane parallel to the ZY-plane.
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • origin

      public Vector3 origin()
      Returns the value of the origin record component.
      Returns:
      the value of the origin record component
    • normal

      public Vector3 normal()
      Returns the value of the normal record component.
      Returns:
      the value of the normal record component