Table of Contents

Struct RaycastHit

Namespace
Thunder.UnitsNET.Vectors.Geometry
Assembly
Thunder.UnitsNET.Vectors.Geometry.dll

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

Distance Length

The arc-length from the ray's origin to the contact point on the shape surface.

Point LengthPoint2

The world-space contact point on the shape surface.

Normal Direction2

The 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

Direction2

Point

The world-space contact point on the shape surface.

public LengthPoint2 Point { get; init; }

Property Value

LengthPoint2
latest ▼