Table of Contents

Struct FixedRay

Namespace
FixedMathSharp.Geometry
Assembly
FixedMathSharp.dll

Represents a ray with an origin and direction in three-dimensional space.

[MemoryPackable(GenerateType.Object)]
public struct FixedRay : IEquatable<FixedRay>, IMemoryPackable<FixedRay>, IMemoryPackFormatterRegister
Implements
IMemoryPackable<FixedRay>
IMemoryPackFormatterRegister
Inherited Members

Remarks

Intersection methods return the ray parameter for the first forward hit. If Direction is normalized, that parameter is also the distance from Position.

Constructors

FixedRay(Vector3d, Vector3d)

Initializes a new ray with the specified origin and direction.

[JsonConstructor]
public FixedRay(Vector3d position, Vector3d direction)

Parameters

position Vector3d
direction Vector3d

Fields

Direction

The direction of the ray.

[JsonInclude]
[MemoryPackOrder(1)]
public Vector3d Direction

Field Value

Vector3d

Position

The origin of the ray.

[JsonInclude]
[MemoryPackOrder(0)]
public Vector3d Position

Field Value

Vector3d

Methods

Deconstruct(out Vector3d, out Vector3d)

Deconstructs the ray into its origin and direction.

public void Deconstruct(out Vector3d position, out Vector3d direction)

Parameters

position Vector3d
direction Vector3d

Equals(FixedRay)

public bool Equals(FixedRay other)

Parameters

other FixedRay

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

GetPoint(Fixed64)

Gets the point at the specified ray parameter with one final round-half-to-even conversion per coordinate.

public Vector3d GetPoint(Fixed64 parameter)

Parameters

parameter Fixed64

Returns

Vector3d

Intersects(FixedBoundBox)

Finds the first forward intersection with the specified bounding box.

public Fixed64? Intersects(FixedBoundBox box)

Parameters

box FixedBoundBox

Returns

Fixed64?

Intersects(FixedBoundFrustum)

Finds the first forward intersection with the specified frustum.

public Fixed64? Intersects(FixedBoundFrustum frustum)

Parameters

frustum FixedBoundFrustum

Returns

Fixed64?

Intersects(FixedBoundSphere)

Finds the first forward intersection with the specified bounding sphere.

public Fixed64? Intersects(FixedBoundSphere sphere)

Parameters

sphere FixedBoundSphere

Returns

Fixed64?

Intersects(FixedBoundSphere, Fixed64)

Finds the first forward intersection with the specified bounding sphere at or before maxParameter.

public Fixed64? Intersects(FixedBoundSphere sphere, Fixed64 maxParameter)

Parameters

sphere FixedBoundSphere
maxParameter Fixed64

Returns

Fixed64?

Remarks

Offset differences, quadratic products, the discriminant, and root ordering are evaluated without fixed-point saturation. The returned parameter uses deterministic round-half-to-even conversion.

Intersects(FixedBoundSphere, Fixed64, Fixed64)

Finds the first forward intersection with the specified bounding sphere, expanded by radiusExpansion, at or before maxParameter.

public Fixed64? Intersects(FixedBoundSphere sphere, Fixed64 radiusExpansion, Fixed64 maxParameter)

Parameters

sphere FixedBoundSphere
radiusExpansion Fixed64
maxParameter Fixed64

Returns

Fixed64?

Remarks

The two radii are combined in wide arithmetic, so their sum may exceed MaxValue without saturation.

Exceptions

ArgumentOutOfRangeException

radiusExpansion is negative.

Intersects(FixedPlane)

Finds the first forward intersection with the specified plane.

public Fixed64? Intersects(FixedPlane plane)

Parameters

plane FixedPlane

Returns

Fixed64?

TryGetCapsuleIntersectionInterval(FixedSegment, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64, out bool, out bool)

Gets the closed parameter interval where this ray overlaps a radially expanded capsule and reports exact bounded-endpoint containment.

public readonly bool TryGetCapsuleIntersectionInterval(FixedSegment capsuleAxis, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

capsuleAxis FixedSegment
radius Fixed64
radiusExpansion Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64
originContained bool
maximumContainedStrict bool

Returns

bool

Remarks

Direction need not be normalized. When it is normalized, returned parameters are physical distances. The origin is tested inclusively; the point at maxParameter is tested strictly.

TryGetCapsuleIntersectionInterval(FixedSegment, Fixed64, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps a capsule, clipped to [0, maxParameter].

public readonly bool TryGetCapsuleIntersectionInterval(FixedSegment capsuleAxis, Fixed64 radius, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

capsuleAxis FixedSegment
radius Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64

Returns

bool

TryGetCapsuleIntersectionInterval(Vector3d, Vector3d, Fixed64, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64, out bool, out bool)

Gets the closed parameter interval where this ray overlaps a centered, radially expanded capsule and reports exact endpoint containment.

public readonly bool TryGetCapsuleIntersectionInterval(Vector3d center, Vector3d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

center Vector3d
axisDirection Vector3d
axisLength Fixed64
radius Fixed64
radiusExpansion Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64
originContained bool
maximumContainedStrict bool

Returns

bool

TryGetCapsuleIntersectionInterval(Vector3d, Vector3d, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps a centered capsule, clipped to [0, maxParameter].

public readonly bool TryGetCapsuleIntersectionInterval(Vector3d center, Vector3d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

center Vector3d
axisDirection Vector3d
axisLength Fixed64
radius Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64

Returns

bool

TryGetFiniteCylinderIntersectionInterval(FixedSegment, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64, out bool, out bool)

Gets the closed parameter interval where this ray overlaps a radially expanded finite cylinder and reports exact endpoint containment.

public readonly bool TryGetFiniteCylinderIntersectionInterval(FixedSegment cylinderAxis, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

cylinderAxis FixedSegment
radius Fixed64
radiusExpansion Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64
originContained bool
maximumContainedStrict bool

Returns

bool

TryGetFiniteCylinderIntersectionInterval(FixedSegment, Fixed64, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps a finite cylinder, clipped to [0, maxParameter].

public readonly bool TryGetFiniteCylinderIntersectionInterval(FixedSegment cylinderAxis, Fixed64 radius, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

cylinderAxis FixedSegment
radius Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64

Returns

bool

TryGetFiniteCylinderIntersectionInterval(Vector3d, Vector3d, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps a centered, affinely expanded finite cylinder.

public readonly bool TryGetFiniteCylinderIntersectionInterval(Vector3d center, Vector3d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 axialExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

center Vector3d
axisDirection Vector3d
axisLength Fixed64
radius Fixed64
radiusExpansion Fixed64
axialExpansion Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64

Returns

bool

TryGetFiniteCylinderIntersectionInterval(Vector3d, Vector3d, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, out Fixed64, out Fixed64, out bool, out bool)

Gets the closed parameter interval where this ray overlaps a centered, affinely expanded finite cylinder and reports exact endpoint containment.

public readonly bool TryGetFiniteCylinderIntersectionInterval(Vector3d center, Vector3d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 axialExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

center Vector3d
axisDirection Vector3d
axisLength Fixed64
radius Fixed64
radiusExpansion Fixed64
axialExpansion Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64
originContained bool
maximumContainedStrict bool

Returns

bool

TryGetIntersectionInterval(FixedBoundSphere, Fixed64, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps the sphere expanded by radiusExpansion, clipped to [0, maxParameter].

public bool TryGetIntersectionInterval(FixedBoundSphere sphere, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entry, out Fixed64 exit)

Parameters

sphere FixedBoundSphere
radiusExpansion Fixed64
maxParameter Fixed64
entry Fixed64
exit Fixed64

Returns

bool

Exceptions

ArgumentOutOfRangeException

radiusExpansion is negative.

TryGetIntersectionInterval(FixedBoundSphere, Fixed64, out Fixed64, out Fixed64)

Gets the closed parameter interval where this ray overlaps the sphere, clipped to [0, maxParameter].

public bool TryGetIntersectionInterval(FixedBoundSphere sphere, Fixed64 maxParameter, out Fixed64 entry, out Fixed64 exit)

Parameters

sphere FixedBoundSphere
maxParameter Fixed64
entry Fixed64
exit Fixed64

Returns

bool

Remarks

Direction need not be normalized. Exact root clipping precedes deterministic round-half-to-even conversion of both endpoints.

TryGetPoint(Fixed64, out Vector3d)

Attempts to get the point at the specified ray parameter with one final round-half-to-even conversion per coordinate.

public readonly bool TryGetPoint(Fixed64 parameter, out Vector3d point)

Parameters

parameter Fixed64

The parametric distance along the ray direction.

point Vector3d

The point when every final coordinate is representable; otherwise, default.

Returns

bool

true when every final coordinate is representable; otherwise, false.

Operators

operator ==(FixedRay, FixedRay)

Determines whether two rays are equal.

public static bool operator ==(FixedRay left, FixedRay right)

Parameters

left FixedRay
right FixedRay

Returns

bool

operator !=(FixedRay, FixedRay)

Determines whether two rays are not equal.

public static bool operator !=(FixedRay left, FixedRay right)

Parameters

left FixedRay
right FixedRay

Returns

bool