Struct RaycastHit
The result of a successful ray-shape intersection test.
public readonly record struct RaycastHit : IEquatable<RaycastHit>
- Implements
- Inherited Members
Examples
var ray = new LengthRay2(LengthPoint2.FromMeters(-3, 0), Direction2.East);
var circle = new Circle2(LengthPoint2.FromMeters(5, 0), Radius.FromMeters(1));
RaycastHit? hit = ray.Intersect(circle);
// hit.Distance == 7 m, hit.Point == (4, 0), hit.Normal == West
Constructors
RaycastHit(Length, LengthPoint2, Direction2)
The result of a successful ray-shape intersection test.
public RaycastHit(Length Distance, LengthPoint2 Point, Direction2 Normal)
Parameters
DistanceLengthThe arc-length from the ray's origin to the contact point on the shape surface.
PointLengthPoint2The world-space contact point on the shape surface.
NormalDirection2The outward surface normal at the contact point, facing toward the ray's origin.
Examples
var ray = new LengthRay2(LengthPoint2.FromMeters(-3, 0), Direction2.East);
var circle = new Circle2(LengthPoint2.FromMeters(5, 0), Radius.FromMeters(1));
RaycastHit? hit = ray.Intersect(circle);
// hit.Distance == 7 m, hit.Point == (4, 0), hit.Normal == West
Properties
Distance
The arc-length from the ray's origin to the contact point on the shape surface.
public Length Distance { get; init; }
Property Value
- Length
Normal
The outward surface normal at the contact point, facing toward the ray's origin.
public Direction2 Normal { get; init; }
Property Value
Point
The world-space contact point on the shape surface.
public LengthPoint2 Point { get; init; }