Class RayCastInput

java.lang.Object
org.jbox2d.collision.RayCastInput

public class RayCastInput extends Object
Ray-cast query input data.

A ray is a directed line segment used to test whether it intersects a fixture.

The ray starts at p1 and extends toward p2. The tested segment is p1 + t * (p2 - p1) for 0 <= t <= maxFraction.

https://www.iforce2d.net/b2dtut/raycasting
Author:
Daniel Murphy
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The maximum normalized distance along the ray to test for intersection.
    final Vec2
    The start point of the ray.
    final Vec2
    The end point used to define the ray direction.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty ray-cast input.
    RayCastInput(Vec2 p1, Vec2 p2, float maxFraction)
    Creates an ray-cast input.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    set(RayCastInput rayCastInput)
    Copies all values from another ray-cast input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • p1

      public final Vec2 p1
      The start point of the ray.
    • p2

      public final Vec2 p2
      The end point used to define the ray direction.

      The direction vector is (p2 - p1).

    • maxFraction

      public float maxFraction
      The maximum normalized distance along the ray to test for intersection.

      1 tests the full segment from p1 to p2; smaller values shorten the tested segment.

  • Constructor Details

    • RayCastInput

      public RayCastInput()
      Creates an empty ray-cast input.
    • RayCastInput

      public RayCastInput(Vec2 p1, Vec2 p2, float maxFraction)
      Creates an ray-cast input.
      Parameters:
      p1 - The start point of the ray.
      p2 - The end point used to define the ray direction.
      maxFraction - The maximum normalized distance along the ray to test for intersection.
  • Method Details

    • set

      public void set(RayCastInput rayCastInput)
      Copies all values from another ray-cast input.
      Parameters:
      rayCastInput - The source input to copy from.