Struct FixedPointAnchor
- Namespace
- FixedMathSharp.Geometry
- Assembly
- FixedMathSharp.dll
Represents a 3D point as a local coordinate in one rigid world-space frame.
public readonly struct FixedPointAnchor : IEquatable<FixedPointAnchor>
- Implements
- Inherited Members
Remarks
Keeping the frame components separate allows full-domain geometry to retain points whose rotated offset or absolute world coordinate is not representable as an intermediate Fixed64 value. Relation-produced anchors can also retain an exact sub-lattice feature term that is intentionally not exposed as a public wide-arithmetic primitive. Consequently, anchors with identical rounded public local components can still compare unequal when they identify distinct exact features.
Constructors
FixedPointAnchor(Vector3d, FixedQuaternion, Vector3d)
Initializes a point anchor from a world origin, normalized local-to-world rotation, and local point.
public FixedPointAnchor(Vector3d origin, FixedQuaternion rotation, Vector3d localPoint)
Parameters
originVector3drotationFixedQuaternionlocalPointVector3d
Exceptions
- ArgumentException
rotationis not normalized.
FixedPointAnchor(Vector3d, FixedQuaternion, Vector3d, Vector3d)
Initializes a point anchor from a world origin, normalized local-to-world rotation, and two additive local-space feature components.
public FixedPointAnchor(Vector3d origin, FixedQuaternion rotation, Vector3d localPoint, Vector3d localDisplacement)
Parameters
originVector3drotationFixedQuaternionlocalPointVector3dlocalDisplacementVector3d
Exceptions
- ArgumentException
rotationis not normalized.
Properties
LocalDisplacement
An additional local-space feature displacement that exact operations add to LocalPoint without a scalar intermediate.
public Vector3d LocalDisplacement { get; }
Property Value
LocalPoint
The point in the rigid frame's local coordinates.
public Vector3d LocalPoint { get; }
Property Value
LocalTranslation
An independent local-space translation applied to the complete anchored point without merging it into either feature component.
public Vector3d LocalTranslation { get; }
Property Value
Origin
The world-space origin of the rigid frame.
public Vector3d Origin { get; }
Property Value
Rotation
The normalized local-to-world rotation of the rigid frame.
public FixedQuaternion Rotation { get; }
Property Value
Methods
CompareLocalFeature(in FixedPointAnchor)
Compares the complete local feature identity of this anchor with
other in deterministic component order.
public int CompareLocalFeature(in FixedPointAnchor other)
Parameters
otherFixedPointAnchor
Returns
Remarks
Frame origin, rotation, and LocalTranslation are intentionally excluded because they move a feature without changing its local identity. Exact sub-lattice centered-axis residuals are included after the public feature components, so distinct features cannot collapse when their rounded local coordinates are equal.
CompareSquaredDistance(in FixedPointAnchor, in FixedPointAnchor)
Compares the exact squared distance from this point to two other anchored points.
public int CompareSquaredDistance(in FixedPointAnchor first, in FixedPointAnchor second)
Parameters
firstFixedPointAnchorsecondFixedPointAnchor
Returns
- int
A negative value when
firstis closer, zero when the distances are equal, or a positive value whensecondis closer.
Equals(FixedPointAnchor)
Returns whether both anchors have identical frames, rounded local components, and any retained exact feature identity.
public bool Equals(FixedPointAnchor other)
Parameters
otherFixedPointAnchor
Returns
Equals(object?)
Returns a hash code for the complete frame and exact feature identity.
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetLocalFeatureHash64()
Returns a stable 64-bit hash of the complete local feature identity.
public ulong GetLocalFeatureHash64()
Returns
ProjectNonNegativeOffsetFrom(in FixedPointAnchor, Vector3d)
Projects this point minus other onto
direction and returns zero for nonpositive results,
the positive projection floored to Q32.32, or
MaxValue when only the final result is
unrepresentable.
public Fixed64 ProjectNonNegativeOffsetFrom(in FixedPointAnchor other, Vector3d direction)
Parameters
otherFixedPointAnchordirectionVector3d
Returns
Exceptions
- InvalidOperationException
This anchor does not contain a normalized rotation.
- ArgumentException
otherdoes not contain a normalized rotation.
TryGetLocalPointIn(Vector3d, FixedQuaternion, out Vector3d)
Attempts to express this point in another rigid frame's local coordinates without first materializing its absolute world position.
public bool TryGetLocalPointIn(Vector3d frameOrigin, FixedQuaternion frameRotation, out Vector3d localPoint)
Parameters
frameOriginVector3dframeRotationFixedQuaternionlocalPointVector3d
Returns
TryGetOffsetFrom(in FixedPointAnchor, out Vector3d)
Attempts to materialize this point's world-space offset from
other.
public bool TryGetOffsetFrom(in FixedPointAnchor other, out Vector3d offset)
Parameters
otherFixedPointAnchoroffsetVector3d
Returns
TryGetPoint(out Vector3d)
Attempts to materialize the absolute world point.
public bool TryGetPoint(out Vector3d point)
Parameters
pointVector3d
Returns
TryGetProjectedOffsetFrom(in FixedPointAnchor, Vector3d, out Fixed64)
Attempts to project this point minus other onto
direction with one final round-half-to-even
conversion.
public bool TryGetProjectedOffsetFrom(in FixedPointAnchor other, Vector3d direction, out Fixed64 projection)
Parameters
otherFixedPointAnchordirectionVector3dprojectionFixed64
Returns
TryGetScaledOffsetFrom(in FixedPointAnchor, Fixed64, out Vector3d)
Attempts to materialize this point's world-space offset from
other after applying scale.
public bool TryGetScaledOffsetFrom(in FixedPointAnchor other, Fixed64 scale, out Vector3d offset)
Parameters
otherFixedPointAnchorscaleFixed64offsetVector3d
Returns
Remarks
The scale is applied to the complete conceptual difference before its final round-half-to-even conversion.
TryReframe(Vector3d, FixedQuaternion, out FixedPointAnchor)
Attempts to express this exact conceptual point in another rigid frame without discarding any sub-lattice feature information.
public bool TryReframe(Vector3d frameOrigin, FixedQuaternion frameRotation, out FixedPointAnchor anchor)
Parameters
frameOriginVector3dframeRotationFixedQuaternionanchorFixedPointAnchor
Returns
Remarks
The operation fails when the target frame would require a general rational local coordinate that a compact point anchor cannot retain.
WithLocalTranslation(Vector3d)
Returns an anchor for the same exact local feature with the specified independent local-space translation.
public FixedPointAnchor WithLocalTranslation(Vector3d localTranslation)
Parameters
localTranslationVector3d
Returns
Operators
operator ==(FixedPointAnchor, FixedPointAnchor)
Returns whether two point anchors have identical frame components.
public static bool operator ==(FixedPointAnchor left, FixedPointAnchor right)
Parameters
leftFixedPointAnchorrightFixedPointAnchor
Returns
operator !=(FixedPointAnchor, FixedPointAnchor)
Returns whether two point anchors have different frame components.
public static bool operator !=(FixedPointAnchor left, FixedPointAnchor right)
Parameters
leftFixedPointAnchorrightFixedPointAnchor