Package limn.math

Record Class Ray


public record Ray(Vec3 origin, Vec3 direction) extends Record
A ray origin + t·direction, t ≥ 0. Used for picking. The direction is stored as given (not re-normalized) so a ray transformed into a model's local space keeps its t parameter consistent with world space.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ray(Vec3 origin, Vec3 direction)
    Creates an instance of a Ray record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the direction record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static Ray
    of(Vec3 origin, Vec3 direction)
    A ray with a normalized direction.
    Returns the value of the origin record component.
    pointAt(float t)
    The point t units along the ray from its origin.
    final String
    Returns a string representation of this record class.
    Brings this ray into another space by m (e.g.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Ray

      public Ray(Vec3 origin, Vec3 direction)
      Creates an instance of a Ray record class.
      Parameters:
      origin - the value for the origin record component
      direction - the value for the direction record component
  • Method Details

    • of

      public static Ray of(Vec3 origin, Vec3 direction)
      A ray with a normalized direction.
    • pointAt

      public Vec3 pointAt(float t)
      The point t units along the ray from its origin.
    • transformedBy

      public Ray transformedBy(Mat4 m)
      Brings this ray into another space by m (e.g. inverse-model, to test triangles in mesh-local space). Direction is transformed as a direction and left un-normalized so t still maps to world distance.
    • toString

      public final 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
    • hashCode

      public final 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
    • equals

      public final 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.
    • origin

      public Vec3 origin()
      Returns the value of the origin record component.
      Returns:
      the value of the origin record component
    • direction

      public Vec3 direction()
      Returns the value of the direction record component.
      Returns:
      the value of the direction record component