< Summary

Information
Class: FixedMathSharp.Geometry.FixedBoundArea
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Bounds/FixedBoundArea.cs
Line coverage
100%
Covered lines: 182
Uncovered lines: 0
Coverable lines: 182
Total lines: 670
Line coverage: 100%
Branch coverage
100%
Covered branches: 66
Total branches: 66
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Bounds/FixedBoundArea.cs

#LineLine coverage
 1//=======================================================================
 2// FixedBoundArea.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024–present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Runtime.CompilerServices;
 10using System.Text.Json.Serialization;
 11using MemoryPack;
 12
 13namespace FixedMathSharp.Geometry;
 14
 15/// <summary>
 16/// Represents a normalized two-dimensional axis-aligned bounding area.
 17/// </summary>
 18/// <remarks>
 19/// FixedMathSharp 2D geometry is plain <see cref="Vector2d"/> plane math. Use
 20/// <see cref="FromMinMax"/>, <see cref="FromCenterAndSize"/>, or
 21/// <see cref="FromCenterAndScope"/> so construction intent is explicit.
 22/// </remarks>
 23[Serializable]
 24[MemoryPackable]
 25public partial struct FixedBoundArea : IEquatable<FixedBoundArea>
 26{
 27    #region Nested Types
 28
 29    /// <summary>
 30    /// Represents the normalized serializable state of a two-dimensional axis-aligned bounding area.
 31    /// </summary>
 32    [Serializable]
 33    [MemoryPackable]
 34    public readonly partial struct BoundingAreaState
 35    {
 36        /// <inheritdoc cref="FixedBoundArea.Min"/>
 37        [JsonInclude]
 38        [MemoryPackInclude]
 39        public readonly Vector2d Min;
 40
 41        /// <inheritdoc cref="FixedBoundArea.Max"/>
 42        [JsonInclude]
 43        [MemoryPackInclude]
 44        public readonly Vector2d Max;
 45
 46        /// <summary>
 47        /// Initializes a normalized state from minimum and maximum corners.
 48        /// </summary>
 49        [JsonConstructor]
 50        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 51        public BoundingAreaState(Vector2d min, Vector2d max)
 52        {
 553            Min = ComponentMin(min, max);
 554            Max = ComponentMax(min, max);
 555        }
 56    }
 57
 58    #endregion
 59
 60    #region Constructors
 61
 62    /// <summary>
 63    /// Initializes a new instance from serialized or caller-provided state.
 64    /// </summary>
 65    [JsonConstructor]
 66    public FixedBoundArea(BoundingAreaState state)
 67    {
 368        State = state;
 369    }
 70
 71    #endregion
 72
 73    #region Properties
 74
 75    /// <summary>
 76    /// The minimum corner of the area.
 77    /// </summary>
 78    [JsonIgnore]
 79    [MemoryPackIgnore]
 80    public Vector2d Min { get; private set; }
 81
 82    /// <summary>
 83    /// The maximum corner of the area.
 84    /// </summary>
 85    [JsonIgnore]
 86    [MemoryPackIgnore]
 87    public Vector2d Max { get; private set; }
 88
 89    /// <summary>
 90    /// The center of the area, rounded to the nearest-even Q32.32 lattice point.
 91    /// </summary>
 92    /// <remarks>
 93    /// Assigning a different center preserves a conservative half-extent. An
 94    /// odd raw-unit span can therefore expand by one raw unit so the assigned
 95    /// center remains exact and the previous area is not under-represented.
 96    /// </remarks>
 97    /// <exception cref="OverflowException">
 98    /// An assigned center would place an endpoint outside the scalar domain.
 99    /// </exception>
 100    [JsonIgnore]
 101    [MemoryPackIgnore]
 102    public Vector2d Center
 103    {
 104        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 16105        get => new(
 16106            FixedMath.Midpoint(Min.X, Max.X),
 16107            FixedMath.Midpoint(Min.Y, Max.Y));
 108
 109        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 110        set
 111        {
 4112            if (value != Center)
 3113                SetCenterAndHalfSize(value, Scope);
 3114        }
 115    }
 116
 117    /// <summary>
 118    /// The exact total width and height of the area.
 119    /// </summary>
 120    /// <remarks>
 121    /// Assigned values are normalized by absolute component value and divided
 122    /// outward. An odd raw-unit size therefore expands by one raw unit. Reading
 123    /// this property throws rather than returning a saturated value when an
 124    /// exact component span is not representable by <see cref="Fixed64"/>.
 125    /// </remarks>
 126    /// <exception cref="OverflowException">
 127    /// A component span is not representable, or an assigned size would place
 128    /// an endpoint outside the scalar domain.
 129    /// </exception>
 130    [JsonIgnore]
 131    [MemoryPackIgnore]
 132    public Vector2d Size
 133    {
 134        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 11135        get => new(
 11136            WideGeometry.GetIntervalSize(Min.X, Max.X),
 11137            WideGeometry.GetIntervalSize(Min.Y, Max.Y));
 138
 139        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 140        set
 141        {
 2142            SetCenterAndHalfSize(Center, GetHalfSize(value));
 1143        }
 144    }
 145
 146    /// <summary>
 147    /// The smallest representable half-extent that conservatively contains the
 148    /// area around <see cref="Center"/>.
 149    /// </summary>
 150    /// <exception cref="OverflowException">
 151    /// A conservative half-extent is outside the representable scalar domain.
 152    /// </exception>
 153    [JsonIgnore]
 154    [MemoryPackIgnore]
 155    public Vector2d Scope
 156    {
 157        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 10158        get => new(
 10159            WideGeometry.GetIntervalScope(Min.X, Max.X),
 10160            WideGeometry.GetIntervalScope(Min.Y, Max.Y));
 161    }
 162
 163    /// <summary>
 164    /// Gets or sets the current normalized state of the area.
 165    /// </summary>
 166    [JsonInclude]
 167    [MemoryPackInclude]
 168    public BoundingAreaState State
 169    {
 2170        get => new(Min, Max);
 171
 172        internal set
 173        {
 3174            SetMinMax(value.Min, value.Max);
 3175        }
 176    }
 177
 178    #endregion
 179
 180    #region Factories
 181
 182    /// <summary>
 183    /// Creates a normalized area from minimum and maximum corners.
 184    /// </summary>
 185    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 186    public static FixedBoundArea FromMinMax(Vector2d min, Vector2d max)
 187    {
 350188        var area = default(FixedBoundArea);
 350189        area.SetMinMax(min, max);
 350190        return area;
 191    }
 192
 193    /// <summary>
 194    /// Creates an area from a center point and total size.
 195    /// </summary>
 196    /// <remarks>
 197    /// Negative size components are normalized by absolute value. Odd raw-unit
 198    /// sizes are divided outward and therefore expand by one raw unit.
 199    /// </remarks>
 200    /// <exception cref="OverflowException">
 201    /// The centered area would place an endpoint outside the scalar domain.
 202    /// </exception>
 203    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 204    public static FixedBoundArea FromCenterAndSize(Vector2d center, Vector2d size)
 205    {
 15206        var area = default(FixedBoundArea);
 15207        area.SetCenterAndHalfSize(center, GetHalfSize(size));
 13208        return area;
 209    }
 210
 211    /// <summary>
 212    /// Creates an area from a center point and half-size scope.
 213    /// </summary>
 214    /// <remarks>
 215    /// Negative scope components are normalized by absolute value.
 216    /// </remarks>
 217    /// <exception cref="OverflowException">
 218    /// A scope magnitude is not representable, or the centered area would
 219    /// place an endpoint outside the scalar domain.
 220    /// </exception>
 221    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 222    public static FixedBoundArea FromCenterAndScope(Vector2d center, Vector2d scope)
 223    {
 2224        var area = default(FixedBoundArea);
 2225        area.SetCenterAndHalfSize(center, GetScopeMagnitude(scope));
 1226        return area;
 227    }
 228
 229    /// <summary>
 230    /// Creates the representable-domain intersection of an area described by a
 231    /// center point and total size.
 232    /// </summary>
 233    /// <remarks>
 234    /// Negative size components are normalized by absolute value and odd raw-
 235    /// unit sizes divide outward. Endpoints outside the scalar domain are
 236    /// explicitly clipped to <see cref="Fixed64.MinValue"/> or
 237    /// <see cref="Fixed64.MaxValue"/>.
 238    /// </remarks>
 239    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 240    public static FixedBoundArea FromCenterAndSizeClippedToDomain(Vector2d center, Vector2d size)
 241    {
 1242        var area = default(FixedBoundArea);
 1243        area.SetCenterAndHalfSizeClippedToDomain(center, GetHalfSize(size));
 1244        return area;
 245    }
 246
 247    /// <summary>
 248    /// Creates the representable-domain intersection of an area described by a
 249    /// center point and half-size scope.
 250    /// </summary>
 251    /// <remarks>
 252    /// Negative scope components are normalized by absolute value. Endpoints
 253    /// outside the scalar domain are explicitly clipped to
 254    /// <see cref="Fixed64.MinValue"/> or <see cref="Fixed64.MaxValue"/>.
 255    /// </remarks>
 256    /// <exception cref="OverflowException">
 257    /// A scope magnitude is not representable.
 258    /// </exception>
 259    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 260    public static FixedBoundArea FromCenterAndScopeClippedToDomain(Vector2d center, Vector2d scope)
 261    {
 5262        var area = default(FixedBoundArea);
 5263        area.SetCenterAndHalfSizeClippedToDomain(center, GetScopeMagnitude(scope));
 5264        return area;
 265    }
 266
 267    /// <summary>
 268    /// Creates the representable-domain intersection of bounds described by a
 269    /// center and normalized center-relative minimum and maximum offsets.
 270    /// </summary>
 271    /// <remarks>
 272    /// Each endpoint is formed by one final saturating add, which is the
 273    /// explicit clipping operation. Asymmetric offsets are preserved.
 274    /// </remarks>
 275    /// <exception cref="ArgumentException">
 276    /// A minimum offset component exceeds the matching maximum component.
 277    /// </exception>
 278    public static FixedBoundArea FromCenterAndOffsetsClippedToDomain(
 279        Vector2d center,
 280        Vector2d minimumOffset,
 281        Vector2d maximumOffset)
 282    {
 3283        if (minimumOffset.X > maximumOffset.X
 3284            || minimumOffset.Y > maximumOffset.Y)
 285        {
 2286            throw new ArgumentException(
 2287                "Minimum offsets must not exceed maximum offsets.",
 2288                nameof(minimumOffset));
 289        }
 290
 1291        return FromMinMax(
 1292            center + minimumOffset,
 1293            center + maximumOffset);
 294    }
 295
 296    /// <summary>
 297    /// Creates the representable-domain intersection of bounds around rotated
 298    /// local offsets without materializing any transformed point.
 299    /// </summary>
 300    public static FixedBoundArea FromRotatedOffsetsClippedToDomain(
 301        Vector2d origin,
 302        Fixed64 rotation,
 303        ReadOnlySpan<Vector2d> localOffsets)
 304    {
 3305        if (localOffsets.IsEmpty)
 306        {
 1307            throw new ArgumentException(
 1308                "At least one local offset is required.",
 1309                nameof(localOffsets));
 310        }
 311
 2312        return WideConvex2dRelations.GetBoundsClippedToDomain(
 2313            origin,
 2314            rotation,
 2315            localOffsets);
 316    }
 317
 318    #endregion
 319
 320    #region Mutators
 321
 322    /// <summary>
 323    /// Sets the normalized bounds of the area by specifying minimum and maximum points.
 324    /// </summary>
 325    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 326    public void SetMinMax(Vector2d min, Vector2d max)
 327    {
 354328        Min = ComponentMin(min, max);
 354329        Max = ComponentMax(min, max);
 354330    }
 331
 332    #endregion
 333
 334    #region Spatial Queries
 335
 336    /// <summary>
 337    /// Determines whether the point is inside this area, including the boundary.
 338    /// </summary>
 339    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 340    public bool Contains(Vector2d point)
 341    {
 5342        return point.X >= Min.X && point.X <= Max.X
 5343            && point.Y >= Min.Y && point.Y <= Max.Y;
 344    }
 345
 346    /// <summary>
 347    /// Classifies another area against this area using boundary-inclusive overlap.
 348    /// </summary>
 349    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 350    public FixedEnclosureType Contains(FixedBoundArea area)
 351    {
 3352        if (area.Min.X >= Min.X && area.Max.X <= Max.X
 3353            && area.Min.Y >= Min.Y && area.Max.Y <= Max.Y)
 1354            return FixedEnclosureType.Contains;
 355
 2356        return Intersects(area)
 2357            ? FixedEnclosureType.Intersects
 2358            : FixedEnclosureType.Disjoint;
 359    }
 360
 361    /// <summary>
 362    /// Classifies a circle against this area using boundary-inclusive overlap.
 363    /// </summary>
 364    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 365    public FixedEnclosureType Contains(FixedBoundCircle circle)
 366    {
 9367        if (WideGeometry.ContainsCenteredExtent(Min.X, Max.X, circle.Center.X, circle.Radius)
 9368            && WideGeometry.ContainsCenteredExtent(Min.Y, Max.Y, circle.Center.Y, circle.Radius))
 1369            return FixedEnclosureType.Contains;
 370
 8371        return Intersects(circle)
 8372            ? FixedEnclosureType.Intersects
 8373            : FixedEnclosureType.Disjoint;
 374    }
 375
 376    /// <summary>
 377    /// Determines whether this area overlaps another area, including boundary-only contact.
 378    /// </summary>
 379    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 380    public bool Intersects(FixedBoundArea area)
 381    {
 6382        return Min.X <= area.Max.X && Max.X >= area.Min.X
 6383            && Min.Y <= area.Max.Y && Max.Y >= area.Min.Y;
 384    }
 385
 386    /// <summary>
 387    /// Determines whether this area overlaps a circle, including boundary-only contact.
 388    /// </summary>
 389    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 12390    public bool Intersects(FixedBoundCircle circle) => circle.Intersects(this);
 391
 392    /// <summary>
 393    /// Determines whether this area overlaps another area with positive area on both axes.
 394    /// </summary>
 395    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 396    public bool IntersectsStrict(FixedBoundArea area)
 397    {
 4398        return HasPositiveArea() && area.HasPositiveArea()
 4399            && Min.X < area.Max.X && Max.X > area.Min.X
 4400            && Min.Y < area.Max.Y && Max.Y > area.Min.Y;
 401    }
 402
 403    /// <summary>
 404    /// Determines whether this area overlaps a circle with positive area.
 405    /// </summary>
 406    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 4407    public bool IntersectsStrict(FixedBoundCircle circle) => circle.IntersectsStrict(this);
 408
 409    /// <summary>
 410    /// Clamps a point to the area boundary or interior.
 411    /// </summary>
 412    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 413    public Vector2d ClampPoint(Vector2d point)
 414    {
 27415        return new Vector2d(
 27416            FixedMath.Clamp(point.X, Min.X, Max.X),
 27417            FixedMath.Clamp(point.Y, Min.Y, Max.Y));
 418    }
 419
 420    /// <summary>
 421    /// Projects a point onto this area by clamping it to the boundary or interior.
 422    /// </summary>
 423    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1424    public Vector2d ProjectPoint(Vector2d point) => ClampPoint(point);
 425
 426    #endregion
 427
 428    #region Deconstruction
 429
 430    /// <summary>
 431    /// Deconstructs the area into normalized minimum and maximum corners.
 432    /// </summary>
 433    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 434    public void Deconstruct(out Vector2d min, out Vector2d max)
 435    {
 1436        min = Min;
 1437        max = Max;
 1438    }
 439
 440    #endregion
 441
 442    #region Equality
 443
 444    /// <inheritdoc />
 445    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 446    public bool Equals(FixedBoundArea other)
 447    {
 34448        return Min == other.Min && Max == other.Max;
 449    }
 450
 451    /// <inheritdoc />
 452    public override bool Equals(object? obj)
 453    {
 2454        return obj is FixedBoundArea other && Equals(other);
 455    }
 456
 457    /// <inheritdoc />
 458    public override int GetHashCode()
 459    {
 460        unchecked
 461        {
 3462            int hash = 17;
 3463            hash = (hash * 31) + Min.StateHash;
 3464            hash = (hash * 31) + Max.StateHash;
 3465            return hash;
 466        }
 467    }
 468
 469    /// <summary>
 470    /// Determines whether two areas have the same normalized bounds.
 471    /// </summary>
 472    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 2473    public static bool operator ==(FixedBoundArea left, FixedBoundArea right) => left.Equals(right);
 474
 475    /// <summary>
 476    /// Determines whether two areas have different normalized bounds.
 477    /// </summary>
 478    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 2479    public static bool operator !=(FixedBoundArea left, FixedBoundArea right) => !left.Equals(right);
 480
 481    #endregion
 482
 483    #region Static Operations
 484
 485    /// <summary>
 486    /// Creates a new area that contains both input areas.
 487    /// </summary>
 488    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 489    public static FixedBoundArea Union(FixedBoundArea a, FixedBoundArea b)
 490    {
 1491        return FromMinMax(ComponentMin(a.Min, b.Min), ComponentMax(a.Max, b.Max));
 492    }
 493
 494    #endregion
 495
 496    #region Helpers
 497
 498    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 499    private bool HasPositiveArea()
 500    {
 8501        return Min.X < Max.X && Min.Y < Max.Y;
 502    }
 503
 504    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 505    private static Vector2d ComponentMin(Vector2d a, Vector2d b)
 506    {
 360507        return new Vector2d(FixedMath.Min(a.X, b.X), FixedMath.Min(a.Y, b.Y));
 508    }
 509
 510    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 511    private static Vector2d ComponentMax(Vector2d a, Vector2d b)
 512    {
 360513        return new Vector2d(FixedMath.Max(a.X, b.X), FixedMath.Max(a.Y, b.Y));
 514    }
 515
 516    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 517    private void SetCenterAndHalfSize(Vector2d center, Vector2d halfSize)
 518    {
 21519        if (!Vector2d.TrySubtract(center, halfSize, out Vector2d min)
 21520            || !Vector2d.TryAdd(center, halfSize, out Vector2d max))
 521        {
 4522            throw CreateUnrepresentableBoundsException();
 523        }
 524
 17525        Min = min;
 17526        Max = max;
 17527    }
 528
 529    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 530    private void SetCenterAndHalfSizeClippedToDomain(Vector2d center, Vector2d halfSize)
 531    {
 6532        Vector2d min = center - halfSize;
 6533        Vector2d max = center + halfSize;
 6534        Min = min;
 6535        Max = max;
 6536    }
 537
 538    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 18539    private static Vector2d GetHalfSize(Vector2d size) => new(
 18540        WideGeometry.GetHalfSizeMagnitude(size.X),
 18541        WideGeometry.GetHalfSizeMagnitude(size.Y));
 542
 543    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 7544    private static Vector2d GetScopeMagnitude(Vector2d scope) => new(
 7545        WideGeometry.GetExtentMagnitude(scope.X),
 7546        WideGeometry.GetExtentMagnitude(scope.Y));
 547
 548    private static OverflowException CreateUnrepresentableBoundsException() =>
 4549        new("The centered area places at least one endpoint outside the representable Fixed64 range.");
 550
 551    #endregion
 552
 553    /// <summary>
 554    /// Creates the representable-domain intersection of a centered capsule's
 555    /// tight axis-aligned bounds from its scalar frame rotation.
 556    /// </summary>
 557    /// <remarks>
 558    /// The capsule's local positive Y axis is its center axis. Sine and cosine
 559    /// remain authoritative through the exact finite-axis bound calculation;
 560    /// no rounded normalized world axis is fed back into the geometry.
 561    /// </remarks>
 562    /// <exception cref="ArgumentOutOfRangeException">
 563    /// <paramref name="fullAxisLength"/> or <paramref name="radius"/> is negative.
 564    /// </exception>
 565    public static FixedBoundArea FromCenteredRotatedCapsuleClippedToDomain(
 566        Vector2d center,
 567        Fixed64 rotation,
 568        Fixed64 fullAxisLength,
 569        Fixed64 radius)
 570    {
 6571        if (fullAxisLength < Fixed64.Zero)
 1572            throw new ArgumentOutOfRangeException(nameof(fullAxisLength));
 5573        if (radius < Fixed64.Zero)
 1574            throw new ArgumentOutOfRangeException(nameof(radius));
 575
 4576        Fixed64 axisX = -FixedMath.Sin(rotation);
 4577        Fixed64 axisY = FixedMath.Cos(rotation);
 4578        return FromMinMax(
 4579            new Vector2d(
 4580                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 4581                    center.X,
 4582                    axisX,
 4583                    fullAxisLength,
 4584                    radius,
 4585                    minimum: true),
 4586                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 4587                    center.Y,
 4588                    axisY,
 4589                    fullAxisLength,
 4590                    radius,
 4591                    minimum: true)),
 4592            new Vector2d(
 4593                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 4594                    center.X,
 4595                    axisX,
 4596                    fullAxisLength,
 4597                    radius,
 4598                    minimum: false),
 4599                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 4600                    center.Y,
 4601                    axisY,
 4602                    fullAxisLength,
 4603                    radius,
 4604                    minimum: false)));
 605    }
 606
 607    /// <summary>
 608    /// Creates the representable-domain intersection of a centered capsule's
 609    /// tight axis-aligned bounds from its full center-axis length.
 610    /// </summary>
 611    /// <param name="center">The center of the capsule's axis segment.</param>
 612    /// <param name="axisDirection">The normalized center-axis direction.</param>
 613    /// <param name="fullAxisLength">The nonnegative full center-axis length.</param>
 614    /// <param name="radius">The nonnegative capsule radius.</param>
 615    /// <remarks>
 616    /// Each exact endpoint is clipped to the scalar domain and rounded outward.
 617    /// Zero length and zero radius are valid degenerate capsules.
 618    /// </remarks>
 619    /// <exception cref="ArgumentException">
 620    /// <paramref name="axisDirection"/> is zero or not normalized.
 621    /// </exception>
 622    /// <exception cref="ArgumentOutOfRangeException">
 623    /// <paramref name="fullAxisLength"/> or <paramref name="radius"/> is negative.
 624    /// </exception>
 625    public static FixedBoundArea FromCenteredCapsuleClippedToDomain(
 626        Vector2d center,
 627        Vector2d axisDirection,
 628        Fixed64 fullAxisLength,
 629        Fixed64 radius)
 630    {
 272631        if (!axisDirection.IsNormalized())
 632        {
 2633            throw new ArgumentException(
 2634                "Finite-axis direction must be normalized.",
 2635                nameof(axisDirection));
 636        }
 270637        if (fullAxisLength < Fixed64.Zero)
 1638            throw new ArgumentOutOfRangeException(nameof(fullAxisLength));
 269639        if (radius < Fixed64.Zero)
 1640            throw new ArgumentOutOfRangeException(nameof(radius));
 641
 268642        return FromMinMax(
 268643            new Vector2d(
 268644                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 268645                    center.X,
 268646                    axisDirection.X,
 268647                    fullAxisLength,
 268648                    radius,
 268649                    minimum: true),
 268650                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 268651                    center.Y,
 268652                    axisDirection.Y,
 268653                    fullAxisLength,
 268654                    radius,
 268655                    minimum: true)),
 268656            new Vector2d(
 268657                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 268658                    center.X,
 268659                    axisDirection.X,
 268660                    fullAxisLength,
 268661                    radius,
 268662                    minimum: false),
 268663                WideGeometry.GetCenteredFiniteAxisBoundClippedToDomain(
 268664                    center.Y,
 268665                    axisDirection.Y,
 268666                    fullAxisLength,
 268667                    radius,
 268668                    minimum: false)));
 669    }
 670}

Methods/Properties

.ctor(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
.ctor(FixedMathSharp.Geometry.FixedBoundArea/BoundingAreaState)
get_Center()
set_Center(FixedMathSharp.Vector2d)
get_Size()
set_Size(FixedMathSharp.Vector2d)
get_Scope()
get_State()
set_State(FixedMathSharp.Geometry.FixedBoundArea/BoundingAreaState)
FromMinMax(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromCenterAndSize(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromCenterAndScope(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromCenterAndSizeClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromCenterAndScopeClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromCenterAndOffsetsClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
FromRotatedOffsetsClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>)
SetMinMax(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
Contains(FixedMathSharp.Vector2d)
Contains(FixedMathSharp.Geometry.FixedBoundArea)
Contains(FixedMathSharp.Geometry.FixedBoundCircle)
Intersects(FixedMathSharp.Geometry.FixedBoundArea)
Intersects(FixedMathSharp.Geometry.FixedBoundCircle)
IntersectsStrict(FixedMathSharp.Geometry.FixedBoundArea)
IntersectsStrict(FixedMathSharp.Geometry.FixedBoundCircle)
ClampPoint(FixedMathSharp.Vector2d)
ProjectPoint(FixedMathSharp.Vector2d)
Deconstruct(FixedMathSharp.Vector2d&,FixedMathSharp.Vector2d&)
Equals(FixedMathSharp.Geometry.FixedBoundArea)
Equals(System.Object)
GetHashCode()
op_Equality(FixedMathSharp.Geometry.FixedBoundArea,FixedMathSharp.Geometry.FixedBoundArea)
op_Inequality(FixedMathSharp.Geometry.FixedBoundArea,FixedMathSharp.Geometry.FixedBoundArea)
Union(FixedMathSharp.Geometry.FixedBoundArea,FixedMathSharp.Geometry.FixedBoundArea)
HasPositiveArea()
ComponentMin(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
ComponentMax(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
SetCenterAndHalfSize(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
SetCenterAndHalfSizeClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
GetHalfSize(FixedMathSharp.Vector2d)
GetScopeMagnitude(FixedMathSharp.Vector2d)
CreateUnrepresentableBoundsException()
FromCenteredRotatedCapsuleClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)
FromCenteredCapsuleClippedToDomain(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)