Module org.dyn4j

Class Ray


  • public class Ray
    extends Object
    Implementation of a ray.

    A ray is a vector with a start point.

    Since:
    2.0.0
    Version:
    3.4.0
    Author:
    William Bittle
    • Constructor Detail

      • Ray

        public Ray​(double direction)
        Creates a ray from the origin in the given direction.
        Parameters:
        direction - the direction in radians
        Since:
        3.0.2
      • Ray

        public Ray​(Vector2 direction)
        Creates a ray from the origin in the given direction.
        Parameters:
        direction - the direction
      • Ray

        public Ray​(Vector2 start,
                   double direction)
        Creates a ray from the given start point in the given direction.
        Parameters:
        start - the start point
        direction - the direction in radians
        Since:
        3.0.2
      • Ray

        public Ray​(Vector2 start,
                   Vector2 direction)
        Creates a ray from the given start point in the given direction.
        Parameters:
        start - the start point
        direction - the direction
        Throws:
        NullPointerException - if start or direction is null
        IllegalArgumentException - if direction is the zero vector
    • Method Detail

      • getStart

        public Vector2 getStart()
        Returns the start point.
        Returns:
        Vector2
      • setStart

        public void setStart​(Vector2 start)
        Sets the start point.
        Parameters:
        start - the start point
        Throws:
        NullPointerException - if start is null
      • setDirection

        public void setDirection​(double direction)
        Sets the direction of this ray in radians.
        Parameters:
        direction - the direction in radians
        Since:
        3.0.2
      • getDirection

        public double getDirection()
        Returns the direction of this ray in radians.
        Returns:
        double the direction in radians between [-π, π]
        Since:
        3.0.2
      • setDirection

        public void setDirection​(Vector2 direction)
        Sets the direction.
        Parameters:
        direction - the direction; should be normalized
        Throws:
        NullPointerException - if direction is null
        IllegalArgumentException - if direction is the zero vector
      • getDirectionVector

        public Vector2 getDirectionVector()
        Returns the direction.
        Returns:
        Vector2
        Since:
        3.0.2