Module org.dyn4j

Class Raycast


  • public class Raycast
    extends java.lang.Object
    Represents the result of a Ray cast against (intersecting with) a Convex Shape.

    The point is the point on the Convex Shape where the ray intersects. The normal is the normal of the edge the Ray intersects.

    Since:
    2.0.0
    Version:
    3.0.2
    Author:
    William Bittle
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double distance
      The distance from the start of the Ray to the hit point
      protected Vector2 normal
      The normal at the hit point
      protected Vector2 point
      The hit point
    • Constructor Summary

      Constructors 
      Constructor Description
      Raycast()
      Default constructor.
      Raycast​(Vector2 point, Vector2 normal, double distance)
      Full constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears this object setting all values to their default values.
      double getDistance()
      Returns the distance from the start of the Ray to the hit point.
      Vector2 getNormal()
      Returns the normal at the hit point.
      Vector2 getPoint()
      Returns the hit point.
      void setDistance​(double distance)
      Sets the distance from the start of the Ray to the hit point.
      void setNormal​(Vector2 normal)
      Sets the normal at the hit point.
      void setPoint​(Vector2 point)
      Sets the hit point.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • point

        protected Vector2 point
        The hit point
      • normal

        protected Vector2 normal
        The normal at the hit point
      • distance

        protected double distance
        The distance from the start of the Ray to the hit point
    • Constructor Detail

      • Raycast

        public Raycast()
        Default constructor.
      • Raycast

        public Raycast​(Vector2 point,
                       Vector2 normal,
                       double distance)
        Full constructor.
        Parameters:
        point - the hit point
        normal - the normal at the hit point
        distance - the distance from the start of the Ray to the hit point
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clear

        public void clear()
        Clears this object setting all values to their default values.
      • getPoint

        public Vector2 getPoint()
        Returns the hit point.
        Returns:
        Vector2
      • setPoint

        public void setPoint​(Vector2 point)
        Sets the hit point.
        Parameters:
        point - the hit point
      • getNormal

        public Vector2 getNormal()
        Returns the normal at the hit point.
        Returns:
        Vector2
      • setNormal

        public void setNormal​(Vector2 normal)
        Sets the normal at the hit point.
        Parameters:
        normal - the normal at the hit point
      • getDistance

        public double getDistance()
        Returns the distance from the start of the Ray to the hit point.
        Returns:
        double
      • setDistance

        public void setDistance​(double distance)
        Sets the distance from the start of the Ray to the hit point.
        Parameters:
        distance - the distance