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
Fields
Direction
The direction of the ray.
[JsonInclude]
[MemoryPackOrder(1)]
public Vector2d Direction
Field Value
Position
The origin of the ray.
[JsonInclude]
[MemoryPackOrder(0)]
public Vector2d Position
Field Value
Methods
Deconstruct(out Vector2d, out Vector2d)
Deconstructs the ray into origin and direction.
public void Deconstruct(out Vector2d position, out Vector2d direction)
Parameters
Equals(FixedRay2d)
public bool Equals(FixedRay2d other)
Parameters
otherFixedRay2d
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetPoint(Fixed64)
Gets the point at the specified ray parameter.
public Vector2d GetPoint(Fixed64 parameter)
Parameters
parameterFixed64
Returns
Intersects(FixedBoundArea)
Finds the first forward intersection with the specified bounding area, including boundary-only contact.
public Fixed64? Intersects(FixedBoundArea area)
Parameters
areaFixedBoundArea
Returns
Intersects(FixedBoundCircle)
Finds the first forward intersection with the specified bounding circle, including boundary-only contact.
public Fixed64? Intersects(FixedBoundCircle circle)
Parameters
circleFixedBoundCircle
Returns
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
circleFixedBoundCirclemaxParameterFixed64
Returns
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
circleFixedBoundCircleradiusExpansionFixed64maxParameterFixed64
Returns
Remarks
The two radii are combined in wide arithmetic, so their sum may exceed MaxValue without saturation.
Exceptions
- ArgumentOutOfRangeException
radiusExpansionis 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
capsuleAxisFixedSegment2dradiusFixed64radiusExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
Returns
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
capsuleAxisFixedSegment2dradiusFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
centerVector2daxisDirectionVector2daxisLengthFixed64radiusFixed64radiusExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
Returns
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
centerVector2daxisDirectionVector2daxisLengthFixed64radiusFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
circleFixedBoundCircleradiusExpansionFixed64maxParameterFixed64entryFixed64exitFixed64
Returns
Exceptions
- ArgumentOutOfRangeException
radiusExpansionis 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
circleFixedBoundCirclemaxParameterFixed64entryFixed64exitFixed64
Returns
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
parameterFixed64The parametric distance along the ray direction.
pointVector2dThe point when every final coordinate is representable; otherwise, default.
Returns
Operators
operator ==(FixedRay2d, FixedRay2d)
Determines whether two rays are equal.
public static bool operator ==(FixedRay2d left, FixedRay2d right)
Parameters
leftFixedRay2drightFixedRay2d
Returns
operator !=(FixedRay2d, FixedRay2d)
Determines whether two rays are not equal.
public static bool operator !=(FixedRay2d left, FixedRay2d right)
Parameters
leftFixedRay2drightFixedRay2d