Class Ray2D

  • All Implemented Interfaces:
    Ray2DType

    public final class Ray2D
    extends java.lang.Object
    implements Ray2DType
    Immutable two-dimensional ray type, defined as an origin and a direction vector.
    Since:
    3.0.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Ray2D.Builder
      Builds instances of type Ray2D.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Ray2D.Builder builder()
      Creates a builder for Ray2D.
      static Ray2D copyOf​(Ray2DType instance)
      Creates an immutable copy of a Ray2DType value.
      com.io7m.jtensors.core.unparameterized.vectors.Vector2D direction()  
      com.io7m.jtensors.core.unparameterized.vectors.Vector2D directionInverse()  
      boolean equals​(java.lang.Object another)
      This instance is equal to all instances of Ray2D that have equal attribute values.
      int hashCode()
      Computes a hash code from attributes: origin, direction.
      static Ray2D of​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D origin, com.io7m.jtensors.core.unparameterized.vectors.Vector2D direction)
      Construct a new immutable Ray2D instance.
      com.io7m.jtensors.core.unparameterized.vectors.Vector2D origin()  
      java.lang.String toString()
      Prints the immutable value Ray2D with attribute values.
      Ray2D withDirection​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D value)
      Copy the current immutable object by setting a value for the direction attribute.
      Ray2D withOrigin​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D value)
      Copy the current immutable object by setting a value for the origin attribute.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • origin

        public com.io7m.jtensors.core.unparameterized.vectors.Vector2D origin()
        Specified by:
        origin in interface Ray2DType
        Returns:
        The origin point of this ray
      • direction

        public com.io7m.jtensors.core.unparameterized.vectors.Vector2D direction()
        Specified by:
        direction in interface Ray2DType
        Returns:
        The direction of this ray
      • directionInverse

        public com.io7m.jtensors.core.unparameterized.vectors.Vector2D directionInverse()
        Specified by:
        directionInverse in interface Ray2DType
        Returns:
        The inverted direction of this ray
      • withOrigin

        public final Ray2D withOrigin​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D value)
        Copy the current immutable object by setting a value for the origin attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for origin
        Returns:
        A modified copy of the this object
      • withDirection

        public final Ray2D withDirection​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D value)
        Copy the current immutable object by setting a value for the direction attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for direction
        Returns:
        A modified copy of the this object
      • equals

        public boolean equals​(java.lang.Object another)
        This instance is equal to all instances of Ray2D that have equal attribute values.
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if this is equal to another instance
      • hashCode

        public int hashCode()
        Computes a hash code from attributes: origin, direction.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashCode value
      • toString

        public java.lang.String toString()
        Prints the immutable value Ray2D with attribute values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the value
      • of

        public static Ray2D of​(com.io7m.jtensors.core.unparameterized.vectors.Vector2D origin,
                               com.io7m.jtensors.core.unparameterized.vectors.Vector2D direction)
        Construct a new immutable Ray2D instance.
        Parameters:
        origin - The value for the origin attribute
        direction - The value for the direction attribute
        Returns:
        An immutable Ray2D instance
      • copyOf

        public static Ray2D copyOf​(Ray2DType instance)
        Creates an immutable copy of a Ray2DType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
        Parameters:
        instance - The instance to copy
        Returns:
        A copied immutable Ray2D instance
      • builder

        public static Ray2D.Builder builder()
        Creates a builder for Ray2D.
        Returns:
        A new Ray2D builder