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
Fields
Direction
The direction of the ray.
[JsonInclude]
[MemoryPackOrder(1)]
public Vector3d Direction
Field Value
Position
The origin of the ray.
[JsonInclude]
[MemoryPackOrder(0)]
public Vector3d Position
Field Value
Methods
Deconstruct(out Vector3d, out Vector3d)
Deconstructs the ray into its origin and direction.
public void Deconstruct(out Vector3d position, out Vector3d direction)
Parameters
Equals(FixedRay)
public bool Equals(FixedRay other)
Parameters
otherFixedRay
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 with one final round-half-to-even conversion per coordinate.
public Vector3d GetPoint(Fixed64 parameter)
Parameters
parameterFixed64
Returns
Intersects(FixedBoundBox)
Finds the first forward intersection with the specified bounding box.
public Fixed64? Intersects(FixedBoundBox box)
Parameters
boxFixedBoundBox
Returns
Intersects(FixedBoundFrustum)
Finds the first forward intersection with the specified frustum.
public Fixed64? Intersects(FixedBoundFrustum frustum)
Parameters
frustumFixedBoundFrustum
Returns
Intersects(FixedBoundSphere)
Finds the first forward intersection with the specified bounding sphere.
public Fixed64? Intersects(FixedBoundSphere sphere)
Parameters
sphereFixedBoundSphere
Returns
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
sphereFixedBoundSpheremaxParameterFixed64
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(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
sphereFixedBoundSphereradiusExpansionFixed64maxParameterFixed64
Returns
Remarks
The two radii are combined in wide arithmetic, so their sum may exceed MaxValue without saturation.
Exceptions
- ArgumentOutOfRangeException
radiusExpansionis negative.
Intersects(FixedPlane)
Finds the first forward intersection with the specified plane.
public Fixed64? Intersects(FixedPlane plane)
Parameters
planeFixedPlane
Returns
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
capsuleAxisFixedSegmentradiusFixed64radiusExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
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(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
capsuleAxisFixedSegmentradiusFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
centerVector3daxisDirectionVector3daxisLengthFixed64radiusFixed64radiusExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
Returns
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
centerVector3daxisDirectionVector3daxisLengthFixed64radiusFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
cylinderAxisFixedSegmentradiusFixed64radiusExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
Returns
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
cylinderAxisFixedSegmentradiusFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
centerVector3daxisDirectionVector3daxisLengthFixed64radiusFixed64radiusExpansionFixed64axialExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64
Returns
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
centerVector3daxisDirectionVector3daxisLengthFixed64radiusFixed64radiusExpansionFixed64axialExpansionFixed64maxParameterFixed64entryParameterFixed64exitParameterFixed64originContainedboolmaximumContainedStrictbool
Returns
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
sphereFixedBoundSphereradiusExpansionFixed64maxParameterFixed64entryFixed64exitFixed64
Returns
Exceptions
- ArgumentOutOfRangeException
radiusExpansionis 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
sphereFixedBoundSpheremaxParameterFixed64entryFixed64exitFixed64
Returns
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
parameterFixed64The parametric distance along the ray direction.
pointVector3dThe point when every final coordinate is representable; otherwise, default.
Returns
Operators
operator ==(FixedRay, FixedRay)
Determines whether two rays are equal.
public static bool operator ==(FixedRay left, FixedRay right)
Parameters
Returns
operator !=(FixedRay, FixedRay)
Determines whether two rays are not equal.
public static bool operator !=(FixedRay left, FixedRay right)