Struct FixedBoundArea
- Namespace
- FixedMathSharp.Geometry
- Assembly
- FixedMathSharp.dll
Represents a normalized two-dimensional axis-aligned bounding area.
[MemoryPackable(GenerateType.Object)]
public struct FixedBoundArea : IEquatable<FixedBoundArea>, IMemoryPackable<FixedBoundArea>, IMemoryPackFormatterRegister
- Implements
-
IMemoryPackable<FixedBoundArea>IMemoryPackFormatterRegister
- Inherited Members
Remarks
FixedMathSharp 2D geometry is plain Vector2d plane math. Use FromMinMax(Vector2d, Vector2d), FromCenterAndSize(Vector2d, Vector2d), or FromCenterAndScope(Vector2d, Vector2d) so construction intent is explicit.
Constructors
FixedBoundArea(BoundingAreaState)
Initializes a new instance from serialized or caller-provided state.
[JsonConstructor]
public FixedBoundArea(FixedBoundArea.BoundingAreaState state)
Parameters
Properties
Center
The center of the area, rounded to the nearest-even Q32.32 lattice point.
[JsonIgnore]
[MemoryPackIgnore]
public Vector2d Center { get; set; }
Property Value
Remarks
Assigning a different center preserves a conservative half-extent. An odd raw-unit span can therefore expand by one raw unit so the assigned center remains exact and the previous area is not under-represented.
Exceptions
- OverflowException
An assigned center would place an endpoint outside the scalar domain.
Max
The maximum corner of the area.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector2d Max { get; }
Property Value
Min
The minimum corner of the area.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector2d Min { get; }
Property Value
Scope
The smallest representable half-extent that conservatively contains the area around Center.
[JsonIgnore]
[MemoryPackIgnore]
public Vector2d Scope { get; }
Property Value
Exceptions
- OverflowException
A conservative half-extent is outside the representable scalar domain.
Size
The exact total width and height of the area.
[JsonIgnore]
[MemoryPackIgnore]
public Vector2d Size { get; set; }
Property Value
Remarks
Assigned values are normalized by absolute component value and divided outward. An odd raw-unit size therefore expands by one raw unit. Reading this property throws rather than returning a saturated value when an exact component span is not representable by Fixed64.
Exceptions
- OverflowException
A component span is not representable, or an assigned size would place an endpoint outside the scalar domain.
State
Gets or sets the current normalized state of the area.
[JsonInclude]
[MemoryPackInclude]
public FixedBoundArea.BoundingAreaState State { get; }
Property Value
Methods
ClampPoint(Vector2d)
Clamps a point to the area boundary or interior.
public Vector2d ClampPoint(Vector2d point)
Parameters
pointVector2d
Returns
Contains(FixedBoundArea)
Classifies another area against this area using boundary-inclusive overlap.
public FixedEnclosureType Contains(FixedBoundArea area)
Parameters
areaFixedBoundArea
Returns
Contains(FixedBoundCircle)
Classifies a circle against this area using boundary-inclusive overlap.
public FixedEnclosureType Contains(FixedBoundCircle circle)
Parameters
circleFixedBoundCircle
Returns
Contains(Vector2d)
Determines whether the point is inside this area, including the boundary.
public bool Contains(Vector2d point)
Parameters
pointVector2d
Returns
Deconstruct(out Vector2d, out Vector2d)
Deconstructs the area into normalized minimum and maximum corners.
public void Deconstruct(out Vector2d min, out Vector2d max)
Parameters
Equals(FixedBoundArea)
public bool Equals(FixedBoundArea other)
Parameters
otherFixedBoundArea
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
FromCenterAndOffsetsClippedToDomain(Vector2d, Vector2d, Vector2d)
Creates the representable-domain intersection of bounds described by a center and normalized center-relative minimum and maximum offsets.
public static FixedBoundArea FromCenterAndOffsetsClippedToDomain(Vector2d center, Vector2d minimumOffset, Vector2d maximumOffset)
Parameters
Returns
Remarks
Each endpoint is formed by one final saturating add, which is the explicit clipping operation. Asymmetric offsets are preserved.
Exceptions
- ArgumentException
A minimum offset component exceeds the matching maximum component.
FromCenterAndScope(Vector2d, Vector2d)
Creates an area from a center point and half-size scope.
public static FixedBoundArea FromCenterAndScope(Vector2d center, Vector2d scope)
Parameters
Returns
Remarks
Negative scope components are normalized by absolute value.
Exceptions
- OverflowException
A scope magnitude is not representable, or the centered area would place an endpoint outside the scalar domain.
FromCenterAndScopeClippedToDomain(Vector2d, Vector2d)
Creates the representable-domain intersection of an area described by a center point and half-size scope.
public static FixedBoundArea FromCenterAndScopeClippedToDomain(Vector2d center, Vector2d scope)
Parameters
Returns
Remarks
Negative scope components are normalized by absolute value. Endpoints outside the scalar domain are explicitly clipped to MinValue or MaxValue.
Exceptions
- OverflowException
A scope magnitude is not representable.
FromCenterAndSize(Vector2d, Vector2d)
Creates an area from a center point and total size.
public static FixedBoundArea FromCenterAndSize(Vector2d center, Vector2d size)
Parameters
Returns
Remarks
Negative size components are normalized by absolute value. Odd raw-unit sizes are divided outward and therefore expand by one raw unit.
Exceptions
- OverflowException
The centered area would place an endpoint outside the scalar domain.
FromCenterAndSizeClippedToDomain(Vector2d, Vector2d)
Creates the representable-domain intersection of an area described by a center point and total size.
public static FixedBoundArea FromCenterAndSizeClippedToDomain(Vector2d center, Vector2d size)
Parameters
Returns
Remarks
Negative size components are normalized by absolute value and odd raw- unit sizes divide outward. Endpoints outside the scalar domain are explicitly clipped to MinValue or MaxValue.
FromCenteredCapsuleClippedToDomain(Vector2d, Vector2d, Fixed64, Fixed64)
Creates the representable-domain intersection of a centered capsule's tight axis-aligned bounds from its full center-axis length.
public static FixedBoundArea FromCenteredCapsuleClippedToDomain(Vector2d center, Vector2d axisDirection, Fixed64 fullAxisLength, Fixed64 radius)
Parameters
centerVector2dThe center of the capsule's axis segment.
axisDirectionVector2dThe normalized center-axis direction.
fullAxisLengthFixed64The nonnegative full center-axis length.
radiusFixed64The nonnegative capsule radius.
Returns
Remarks
Each exact endpoint is clipped to the scalar domain and rounded outward. Zero length and zero radius are valid degenerate capsules.
Exceptions
- ArgumentException
axisDirectionis zero or not normalized.- ArgumentOutOfRangeException
fullAxisLengthorradiusis negative.
FromCenteredRotatedCapsuleClippedToDomain(Vector2d, Fixed64, Fixed64, Fixed64)
Creates the representable-domain intersection of a centered capsule's tight axis-aligned bounds from its scalar frame rotation.
public static FixedBoundArea FromCenteredRotatedCapsuleClippedToDomain(Vector2d center, Fixed64 rotation, Fixed64 fullAxisLength, Fixed64 radius)
Parameters
Returns
Remarks
The capsule's local positive Y axis is its center axis. Sine and cosine remain authoritative through the exact finite-axis bound calculation; no rounded normalized world axis is fed back into the geometry.
Exceptions
- ArgumentOutOfRangeException
fullAxisLengthorradiusis negative.
FromMinMax(Vector2d, Vector2d)
Creates a normalized area from minimum and maximum corners.
public static FixedBoundArea FromMinMax(Vector2d min, Vector2d max)
Parameters
Returns
FromRotatedOffsetsClippedToDomain(Vector2d, Fixed64, ReadOnlySpan<Vector2d>)
Creates the representable-domain intersection of bounds around rotated local offsets without materializing any transformed point.
public static FixedBoundArea FromRotatedOffsetsClippedToDomain(Vector2d origin, Fixed64 rotation, ReadOnlySpan<Vector2d> localOffsets)
Parameters
originVector2drotationFixed64localOffsetsReadOnlySpan<Vector2d>
Returns
GetHashCode()
public override int GetHashCode()
Returns
Intersects(FixedBoundArea)
Determines whether this area overlaps another area, including boundary-only contact.
public bool Intersects(FixedBoundArea area)
Parameters
areaFixedBoundArea
Returns
Intersects(FixedBoundCircle)
Determines whether this area overlaps a circle, including boundary-only contact.
public bool Intersects(FixedBoundCircle circle)
Parameters
circleFixedBoundCircle
Returns
IntersectsStrict(FixedBoundArea)
Determines whether this area overlaps another area with positive area on both axes.
public bool IntersectsStrict(FixedBoundArea area)
Parameters
areaFixedBoundArea
Returns
IntersectsStrict(FixedBoundCircle)
Determines whether this area overlaps a circle with positive area.
public bool IntersectsStrict(FixedBoundCircle circle)
Parameters
circleFixedBoundCircle
Returns
ProjectPoint(Vector2d)
Projects a point onto this area by clamping it to the boundary or interior.
public Vector2d ProjectPoint(Vector2d point)
Parameters
pointVector2d
Returns
SetMinMax(Vector2d, Vector2d)
Sets the normalized bounds of the area by specifying minimum and maximum points.
public void SetMinMax(Vector2d min, Vector2d max)
Parameters
Union(FixedBoundArea, FixedBoundArea)
Creates a new area that contains both input areas.
public static FixedBoundArea Union(FixedBoundArea a, FixedBoundArea b)
Parameters
Returns
Operators
operator ==(FixedBoundArea, FixedBoundArea)
Determines whether two areas have the same normalized bounds.
public static bool operator ==(FixedBoundArea left, FixedBoundArea right)
Parameters
leftFixedBoundArearightFixedBoundArea
Returns
operator !=(FixedBoundArea, FixedBoundArea)
Determines whether two areas have different normalized bounds.
public static bool operator !=(FixedBoundArea left, FixedBoundArea right)
Parameters
leftFixedBoundArearightFixedBoundArea