Record Class Winding

java.lang.Object
java.lang.Record
com.j3d.engine.scene.nodes.geometry.base.Winding
Record Components:
first - The first point in the winding.
second - The second point in the winding.
third - The third point in the winding.

public record Winding(GPoint first, GPoint second, GPoint third) extends Record
Represents a winding of three GPoints, typically used to define a triangle or a face in 2D geometry. This record provides utility methods for converting the winding to lists of points or vectors, reversing its order, and generating a string representation.
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • first

      private final GPoint first
      The field for the first record component.
    • second

      private final GPoint second
      The field for the second record component.
    • third

      private final GPoint third
      The field for the third record component.
  • Constructor Details

    • Winding

      public Winding(GPoint first, GPoint second, GPoint third)
      Creates an instance of a Winding record class.
      Parameters:
      first - the value for the first record component
      second - the value for the second record component
      third - the value for the third record component
  • Method Details

    • toList

      public List<GPoint> toList()
      Converts the winding into an ordered list of its constituent GPoints.
      Returns:
      A List containing the first, second, and third points of the winding in order.
    • toVector3List

      public List<Vector3> toVector3List()
      Converts the winding into an ordered list of its constituent Vector3 pivots.
      Returns:
      A List containing the Vector3 pivots of the first, second, and third points of the winding in order.
    • reverse

      public Winding reverse()
      Creates a new Winding with the order of its points reversed. The new winding will have the third point as its first, the second point remaining as second, and the first point as its third.
      Returns:
      A new Winding instance with the points in reverse order.
    • normal

      public Vector3 normal()
    • id

      private String id(GPoint point)
      Helper method to get a truncated string representation of a GPoint's ID.
      Parameters:
      point - The GPoint whose ID is to be truncated.
      Returns:
      A string representing the first three characters of the point's ID.
    • toString

      public String toString()
      Returns a string representation of the winding, showing the truncated IDs of its constituent points in the format "[first_id -> second_id -> third_id]".
      Specified by:
      toString in class Record
    • 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
    • stream

      public Stream<GPoint> stream()
    • first

      public GPoint first()
      Returns the value of the first record component.
      Returns:
      the value of the first record component
    • second

      public GPoint second()
      Returns the value of the second record component.
      Returns:
      the value of the second record component
    • third

      public GPoint third()
      Returns the value of the third record component.
      Returns:
      the value of the third record component