Table of Contents

Struct FixedRay2d

Namespace
FixedMathSharp.Geometry
Assembly
FixedMathSharp.dll

Represents a ray with an origin and direction in two-dimensional fixed-point space.

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

Remarks

The direction is not normalized by construction. Intersection methods return the ray parameter for the first forward hit; when Direction is normalized, that parameter is also the distance from Position.

Constructors

FixedRay2d(Vector2d, Vector2d)

Initializes a new ray with the specified origin and direction.

[JsonConstructor]
public FixedRay2d(Vector2d position, Vector2d direction)

Parameters

position Vector2d
direction Vector2d

Fields

Direction

The direction of the ray.

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

Field Value

Vector2d

Position

The origin of the ray.

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

Field Value

Vector2d

Methods

Deconstruct(out Vector2d, out Vector2d)

Deconstructs the ray into origin and direction.

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

Parameters

position Vector2d
direction Vector2d

Equals(FixedRay2d)

public bool Equals(FixedRay2d other)

Parameters

other FixedRay2d

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.

public Vector2d GetPoint(Fixed64 parameter)

Parameters

parameter Fixed64

Returns

Vector2d

Intersects(FixedBoundArea)

Finds the first forward intersection with the specified bounding area, including boundary-only contact.

public Fixed64? Intersects(FixedBoundArea area)

Parameters

area FixedBoundArea

Returns

Fixed64?

Intersects(FixedBoundCircle)

Finds the first forward intersection with the specified bounding circle, including boundary-only contact.

public Fixed64? Intersects(FixedBoundCircle circle)

Parameters

circle FixedBoundCircle

Returns

Fixed64?

Intersects(FixedBoundCircle, Fixed64)

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

public Fixed64? Intersects(FixedBoundCircle circle, Fixed64 maxParameter)

Parameters

circle FixedBoundCircle
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(FixedBoundCircle, Fixed64, Fixed64)

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

public Fixed64? Intersects(FixedBoundCircle circle, Fixed64 radiusExpansion, Fixed64 maxParameter)

Parameters

circle FixedBoundCircle
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.

TryGetCapsuleIntersectionInterval(FixedSegment2d, 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(FixedSegment2d capsuleAxis, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

capsuleAxis FixedSegment2d
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(FixedSegment2d, 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(FixedSegment2d capsuleAxis, Fixed64 radius, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

capsuleAxis FixedSegment2d
radius Fixed64
maxParameter Fixed64
entryParameter Fixed64
exitParameter Fixed64

Returns

bool

TryGetCapsuleIntersectionInterval(Vector2d, Vector2d, 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(Vector2d center, Vector2d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter, out bool originContained, out bool maximumContainedStrict)

Parameters

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

Returns

bool

TryGetCapsuleIntersectionInterval(Vector2d, Vector2d, 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(Vector2d center, Vector2d axisDirection, Fixed64 axisLength, Fixed64 radius, Fixed64 maxParameter, out Fixed64 entryParameter, out Fixed64 exitParameter)

Parameters

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

Returns

bool

TryGetIntersectionInterval(FixedBoundCircle, Fixed64, Fixed64, out Fixed64, out Fixed64)

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

public bool TryGetIntersectionInterval(FixedBoundCircle circle, Fixed64 radiusExpansion, Fixed64 maxParameter, out Fixed64 entry, out Fixed64 exit)

Parameters

circle FixedBoundCircle
radiusExpansion Fixed64
maxParameter Fixed64
entry Fixed64
exit Fixed64

Returns

bool

Exceptions

ArgumentOutOfRangeException

radiusExpansion is negative.

TryGetIntersectionInterval(FixedBoundCircle, Fixed64, out Fixed64, out Fixed64)

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

public bool TryGetIntersectionInterval(FixedBoundCircle circle, Fixed64 maxParameter, out Fixed64 entry, out Fixed64 exit)

Parameters

circle FixedBoundCircle
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 Vector2d)

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 Vector2d point)

Parameters

parameter Fixed64

The parametric distance along the ray direction.

point Vector2d

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

Returns

bool

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

Operators

operator ==(FixedRay2d, FixedRay2d)

Determines whether two rays are equal.

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

Parameters

left FixedRay2d
right FixedRay2d

Returns

bool

operator !=(FixedRay2d, FixedRay2d)

Determines whether two rays are not equal.

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

Parameters

left FixedRay2d
right FixedRay2d

Returns

bool