Package arc.math.geom

Class Ray

java.lang.Object
arc.math.geom.Ray

public class Ray extends Object
Encapsulates a ray having a starting position and a unit length direction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Vec3
     
    final Vec3
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ray()
     
    Ray(Vec3 origin, Vec3 direction)
    Constructor, sets the starting position of the ray and the direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    cpy()
     
    boolean
     
    getEndPoint(Vec3 out, float distance)
    Returns the endpoint given the distance.
    int
     
    set(float x, float y, float z, float dx, float dy, float dz)
    Sets this ray from the given starting position and direction.
    set(Ray ray)
    Sets the starting position and direction from the given ray
    set(Vec3 origin, Vec3 direction)
    Sets the starting position and the direction of this ray.

    Methods inherited from class java.lang.Object

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

    • origin

      public final Vec3 origin
    • direction

      public final Vec3 direction
  • Constructor Details

    • Ray

      public Ray()
    • Ray

      public Ray(Vec3 origin, Vec3 direction)
      Constructor, sets the starting position of the ray and the direction.
      Parameters:
      origin - The starting position
      direction - The direction
  • Method Details

    • cpy

      public Ray cpy()
      Returns:
      a copy of this ray.
    • getEndPoint

      public Vec3 getEndPoint(Vec3 out, float distance)
      Returns the endpoint given the distance. This is calculated as startpoint + distance * direction.
      Parameters:
      out - The vector to set to the result
      distance - The distance from the end point to the start point.
      Returns:
      The out param
    • set

      public Ray set(Vec3 origin, Vec3 direction)
      Sets the starting position and the direction of this ray.
      Parameters:
      origin - The starting position
      direction - The direction
      Returns:
      this ray for chaining
    • set

      public Ray set(float x, float y, float z, float dx, float dy, float dz)
      Sets this ray from the given starting position and direction.
      Parameters:
      x - The x-component of the starting position
      y - The y-component of the starting position
      z - The z-component of the starting position
      dx - The x-component of the direction
      dy - The y-component of the direction
      dz - The z-component of the direction
      Returns:
      this ray for chaining
    • set

      public Ray set(Ray ray)
      Sets the starting position and direction from the given ray
      Parameters:
      ray - The ray
      Returns:
      This ray for chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object