Class RayCastOutput

java.lang.Object
org.jbox2d.collision.RayCastOutput

public class RayCastOutput extends Object
Ray-cast result data.

If an intersection is found, the hit position can be reconstructed as p1 + fraction * (p2 - p1), where p1 and p2 come from RayCastInput.

This object stores only the hit fraction and surface normal. It does not store the hit point directly.

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

    Fields
    Modifier and Type
    Field
    Description
    float
    Fraction along the input ray where the intersection occurs.
    final Vec2
    Surface normal at the intersection point.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty ray-cast result.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    set(RayCastOutput rayCastOutput)
    Copies all values from another ray-cast result.

    Methods inherited from class java.lang.Object

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

    • normal

      public final Vec2 normal
      Surface normal at the intersection point.

      This vector points away from the hit surface.

    • fraction

      public float fraction
      Fraction along the input ray where the intersection occurs.

      A value of 0 is at p1; a value of 1 is at p2 when maxFraction == 1.

  • Constructor Details

    • RayCastOutput

      public RayCastOutput()
      Creates an empty ray-cast result.
  • Method Details

    • set

      public void set(RayCastOutput rayCastOutput)
      Copies all values from another ray-cast result.
      Parameters:
      rayCastOutput - The source result to copy from.