< Summary

Information
Class: FixedMathSharp.Geometry.WideCenteredCapsule2dRelations
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/Convex/WideCenteredCapsule2dRelations.cs
Line coverage
100%
Covered lines: 470
Uncovered lines: 0
Coverable lines: 470
Total lines: 692
Line coverage: 100%
Branch coverage
100%
Covered branches: 70
Total branches: 70
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
TryGetMinimumTranslation(...)100%11100%
TryGetMinimumTranslation(...)100%11100%
TryGetContacts(...)100%1212100%
GetCenteredCapsuleSideAnchor(...)100%11100%
TryGetMinimumTranslation(...)100%1414100%
GetClosestVertexAxis(...)100%88100%
GetDirectionFromCenteredAxis(...)100%44100%
NarrowProven(...)100%11100%
GetSupportFeature(...)100%1212100%
TryKeepAxis(...)100%1414100%
GetRelativeProjectionRange(...)100%66100%
GetRelativeProjection(...)100%11100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/Convex/WideCenteredCapsule2dRelations.cs

#LineLine coverage
 1//=======================================================================
 2// WideCenteredCapsule2dRelations.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;
 9
 10namespace FixedMathSharp.Geometry;
 11
 12/// <summary>
 13/// Owns rigid-frame full-domain relations for conceptual 2D capsules.
 14/// </summary>
 15internal static class WideCenteredCapsule2dRelations
 16{
 117    private static readonly Fixed64 SideAlignmentTolerance =
 118        Fixed64.Epsilon * (Fixed64)16;
 119    private static readonly Signed192 DoubleScaleSquared =
 120        new(0UL, 2UL, 0UL);
 121    private static readonly Signed192 ScaleSquared =
 122        new(0UL, 1UL, 0UL);
 23
 24    internal static bool TryGetMinimumTranslation(
 25        Vector2d center,
 26        Vector2d capsuleAxis,
 27        Fixed64 axisLength,
 28        Fixed64 radius,
 29        Vector2d convexOrigin,
 30        ReadOnlySpan<Vector2d> convexOriginOffsets,
 31        out Vector2d normal,
 32        out Fixed64 depth) =>
 733        TryGetMinimumTranslation(
 734            center,
 735            capsuleAxis,
 736            axisLength,
 737            radius,
 738            convexOrigin,
 739            Fixed64.Zero,
 740            convexOriginOffsets,
 741            out normal,
 742            out depth);
 43
 44    internal static bool TryGetMinimumTranslation(
 45        Vector2d center,
 46        Vector2d capsuleAxis,
 47        Fixed64 axisLength,
 48        Fixed64 radius,
 49        Vector2d convexOrigin,
 50        Fixed64 convexRotation,
 51        ReadOnlySpan<Vector2d> convexOriginOffsets,
 52        out Vector2d normal,
 53        out Fixed64 depth) =>
 854        TryGetMinimumTranslation(
 855            center,
 856            capsuleAxis,
 857            axisLength,
 858            radius,
 859            convexOrigin,
 860            convexRotation,
 861            convexOriginOffsets,
 862            out normal,
 863            out depth,
 864            out _,
 865            out _);
 66
 67    internal static bool TryGetContacts(
 68        Vector2d capsuleCenter,
 69        Fixed64 capsuleRotation,
 70        Vector2d localCapsuleAxis,
 71        Fixed64 axisLength,
 72        Fixed64 radius,
 73        Vector2d convexOrigin,
 74        Fixed64 convexRotation,
 75        ReadOnlySpan<Vector2d> convexVertexOffsets,
 76        Span<FixedPointAnchor2d> capsuleContacts,
 77        Span<FixedPointAnchor2d> convexContacts,
 78        out int contactCount,
 79        out Vector2d normal,
 80        out Fixed64 depth,
 81        out bool depthIsClamped)
 82    {
 3983        _ = Vector2d.TryRotate(
 3984            localCapsuleAxis,
 3985            capsuleRotation,
 3986            out Vector2d capsuleAxis);
 3987        if (!TryGetMinimumTranslation(
 3988                capsuleCenter,
 3989                capsuleAxis,
 3990                axisLength,
 3991                radius,
 3992                convexOrigin,
 3993                convexRotation,
 3994                convexVertexOffsets,
 3995                out normal,
 3996                out depth,
 3997                out depthIsClamped,
 3998                out bool axisFromEdge))
 99        {
 15100            contactCount = default;
 15101            return false;
 102        }
 103
 24104        _ = Vector2d.TryRotate(
 24105            normal,
 24106            -capsuleRotation,
 24107            out Vector2d localNormal);
 24108        localNormal = localNormal.Normalized;
 24109        GetSupportFeature(
 24110            capsuleCenter,
 24111            convexOrigin,
 24112            convexRotation,
 24113            convexVertexOffsets,
 24114            normal,
 24115            axisFromEdge,
 24116            out Vector2d featureStart,
 24117            out Vector2d featureEnd);
 24118        Vector2d featureDirection = WideNormalization.GetDirection(featureStart, featureEnd);
 24119        if (axisLength > Fixed64.Epsilon
 24120            && featureDirection != Vector2d.Zero
 24121            && Vector2d.Dot(capsuleAxis, normal).Abs()
 24122                <= SideAlignmentTolerance)
 123        {
 7124            FixedPointAnchor2d firstCapsuleAnchor =
 7125                GetCenteredCapsuleSideAnchor(
 7126                    capsuleCenter,
 7127                    capsuleRotation,
 7128                    localCapsuleAxis,
 7129                    -axisLength,
 7130                    localNormal,
 7131                    radius);
 7132            FixedPointAnchor2d secondCapsuleAnchor =
 7133                GetCenteredCapsuleSideAnchor(
 7134                    capsuleCenter,
 7135                    capsuleRotation,
 7136                    localCapsuleAxis,
 7137                    axisLength,
 7138                    localNormal,
 7139                    radius);
 7140            if (WideConvex2dRelations.TryProjectAnchorOntoFeature(
 7141                    firstCapsuleAnchor,
 7142                    convexOrigin,
 7143                    convexRotation,
 7144                    featureStart,
 7145                    featureEnd,
 7146                    requireInteriorProjection: true,
 7147                    out Vector2d firstConvexOffset)
 7148                && WideConvex2dRelations.TryProjectAnchorOntoFeature(
 7149                    secondCapsuleAnchor,
 7150                    convexOrigin,
 7151                    convexRotation,
 7152                    featureStart,
 7153                    featureEnd,
 7154                    requireInteriorProjection: true,
 7155                    out Vector2d secondConvexOffset))
 156            {
 4157                capsuleContacts[0] = firstCapsuleAnchor;
 4158                capsuleContacts[1] = secondCapsuleAnchor;
 4159                convexContacts[0] = new FixedPointAnchor2d(
 4160                    convexOrigin,
 4161                    convexRotation,
 4162                    firstConvexOffset);
 4163                convexContacts[1] = new FixedPointAnchor2d(
 4164                    convexOrigin,
 4165                    convexRotation,
 4166                    secondConvexOffset);
 4167                contactCount = 2;
 4168                return true;
 169            }
 170        }
 171
 20172        FixedPointAnchor2d capsuleContact =
 20173            WideFiniteAxisIntersection.GetCenteredCapsuleSupportAnchor(
 20174                capsuleCenter,
 20175                capsuleRotation,
 20176                localCapsuleAxis,
 20177                axisLength,
 20178                radius,
 20179                localNormal);
 20180        _ = WideConvex2dRelations.TryProjectAnchorOntoFeature(
 20181            capsuleContact,
 20182            convexOrigin,
 20183            convexRotation,
 20184            featureStart,
 20185            featureEnd,
 20186            requireInteriorProjection: false,
 20187            out Vector2d convexOffset);
 188
 20189        capsuleContacts[0] = capsuleContact;
 20190        convexContacts[0] = new FixedPointAnchor2d(
 20191            convexOrigin,
 20192            convexRotation,
 20193            convexOffset);
 20194        contactCount = 1;
 20195        return true;
 196    }
 197
 198    private static FixedPointAnchor2d GetCenteredCapsuleSideAnchor(
 199        Vector2d center,
 200        Fixed64 rotation,
 201        Vector2d localAxis,
 202        Fixed64 signedAxisLength,
 203        Vector2d localRadialDirection,
 204        Fixed64 radius)
 205    {
 14206        Vector2d axialOffset =
 14207            localAxis * (signedAxisLength / Fixed64.Two);
 14208        Vector2d radialOffset = localRadialDirection * radius;
 14209        FixedPointAnchorTerm2d exactLocalTerm =
 14210            FixedPointAnchorTerm2d.CreateCenteredAxisSupport(
 14211                localAxis,
 14212                signedAxisLength,
 14213                localRadialDirection,
 14214                radius,
 14215                axialOffset,
 14216                radialOffset);
 14217        return new FixedPointAnchor2d(
 14218            center,
 14219            rotation,
 14220            axialOffset,
 14221            radialOffset,
 14222            exactLocalTerm);
 223    }
 224
 225    private static bool TryGetMinimumTranslation(
 226        Vector2d center,
 227        Vector2d capsuleAxis,
 228        Fixed64 axisLength,
 229        Fixed64 radius,
 230        Vector2d convexOrigin,
 231        Fixed64 convexRotation,
 232        ReadOnlySpan<Vector2d> convexOriginOffsets,
 233        out Vector2d normal,
 234        out Fixed64 depth,
 235        out bool depthIsClamped,
 236        out bool bestAxisFromEdge)
 237    {
 47238        bool found = false;
 47239        Signed576 bestDepth = default;
 47240        Vector2d bestNormal = default;
 47241        bestAxisFromEdge = false;
 242
 378243        for (int i = 0; i < convexOriginOffsets.Length; i++)
 244        {
 155245            Vector2d edgeDirection = WideConvex2dRelations.GetTransformedEdgeDirection(
 155246                convexRotation,
 155247                convexOriginOffsets[i],
 155248                convexOriginOffsets[(i + 1) % convexOriginOffsets.Length]);
 155249            if (edgeDirection == Vector2d.Zero)
 250                continue;
 251
 150252            Vector2d edgeNormal = new(-edgeDirection.Y, edgeDirection.X);
 150253            if (!TryKeepAxis(
 150254                    center,
 150255                    capsuleAxis,
 150256                    axisLength,
 150257                    radius,
 150258                    convexOrigin,
 150259                    convexRotation,
 150260                    convexOriginOffsets,
 150261                    edgeNormal,
 150262                    true,
 150263                    ref found,
 150264                    ref bestDepth,
 150265                    ref bestNormal,
 150266                    ref bestAxisFromEdge))
 267            {
 13268                normal = default;
 13269                depth = default;
 13270                depthIsClamped = default;
 13271                return false;
 272            }
 273        }
 274
 34275        Vector2d closestAxis = GetClosestVertexAxis(
 34276            center,
 34277            capsuleAxis,
 34278            axisLength,
 34279            convexOrigin,
 34280            convexRotation,
 34281            convexOriginOffsets);
 34282        if (closestAxis != Vector2d.Zero
 34283            && !TryKeepAxis(
 34284                center,
 34285                capsuleAxis,
 34286                axisLength,
 34287                radius,
 34288                convexOrigin,
 34289                convexRotation,
 34290                convexOriginOffsets,
 34291                closestAxis,
 34292                false,
 34293                ref found,
 34294                ref bestDepth,
 34295                ref bestNormal,
 34296                ref bestAxisFromEdge))
 297        {
 2298            normal = default;
 2299            depth = default;
 2300            depthIsClamped = default;
 2301            return false;
 302        }
 303
 32304        if (!found)
 305        {
 1306            normal = default;
 1307            depth = default;
 1308            depthIsClamped = default;
 1309            return false;
 310        }
 311
 31312        normal = bestNormal;
 31313        if (!Fixed64.TryGetSignedRawRatio(
 31314                bestDepth,
 31315                Signed576.ExtendValue(
 31316                    Signed320.ExtendValue(
 31317                        DoubleScaleSquared)),
 31318                out depth))
 319        {
 2320            depth = Fixed64.MaxValue;
 2321            depthIsClamped = true;
 2322            return true;
 323        }
 324
 29325        depthIsClamped = false;
 29326        return true;
 327    }
 328
 329    private static Vector2d GetClosestVertexAxis(
 330        Vector2d center,
 331        Vector2d capsuleAxis,
 332        Fixed64 axisLength,
 333        Vector2d convexOrigin,
 334        Fixed64 convexRotation,
 335        ReadOnlySpan<Vector2d> convexOriginOffsets)
 336    {
 34337        bool found = false;
 34338        Vector2d bestAxis = default;
 34339        Signed576 bestSquaredDistance = default;
 342340        for (int i = 0; i < convexOriginOffsets.Length; i++)
 341        {
 137342            Vector2d candidate = GetDirectionFromCenteredAxis(
 137343                convexOrigin,
 137344                convexRotation,
 137345                convexOriginOffsets[i],
 137346                center,
 137347                capsuleAxis,
 137348                axisLength,
 137349                out Signed576 candidateSquaredDistance);
 137350            if (candidate == Vector2d.Zero)
 351                continue;
 134352            if (found
 134353                && WideArithmetic.SubtractSigned576(
 134354                    candidateSquaredDistance,
 134355                    bestSquaredDistance).Sign >= 0)
 356            {
 357                continue;
 358            }
 359
 44360            found = true;
 44361            bestAxis = candidate;
 44362            bestSquaredDistance = candidateSquaredDistance;
 363        }
 364
 34365        return bestAxis;
 366    }
 367
 368    private static Vector2d GetDirectionFromCenteredAxis(
 369        Vector2d pointOrigin,
 370        Fixed64 pointRotation,
 371        Vector2d pointOriginOffset,
 372        Vector2d axisCenter,
 373        Vector2d axisDirection,
 374        Fixed64 axisLength,
 375        out Signed576 squaredDistance)
 376    {
 137377        WideConvex2dRelations.GetRelativePointNumerators(
 137378            pointOrigin,
 137379            pointRotation,
 137380            pointOriginOffset,
 137381            axisCenter,
 137382            out Signed192 relativeX,
 137383            out Signed192 relativeY);
 137384        Signed320 projection = WideArithmetic.AddSigned320(
 137385            WideArithmetic.MultiplySigned192(
 137386                relativeX,
 137387                Signed192.Signed(axisDirection.X.m_rawValue)),
 137388            WideArithmetic.MultiplySigned192(
 137389                relativeY,
 137390                Signed192.Signed(axisDirection.Y.m_rawValue)));
 137391        Signed320 doubleProjection =
 137392            WideArithmetic.AddSigned320(projection, projection);
 137393        Signed320 axialThreshold = WideArithmetic.MultiplySigned192(
 137394            Signed192.Signed(axisLength.m_rawValue),
 137395            ScaleSquared);
 396
 397        Signed320 directionX;
 398        Signed320 directionY;
 137399        if (WideArithmetic.SubtractSigned320(
 137400                doubleProjection,
 137401                axialThreshold).Sign > 0)
 402        {
 58403            Signed192 twiceRelativeX =
 58404                WideArithmetic.AddSigned192(relativeX, relativeX);
 58405            Signed192 twiceRelativeY =
 58406                WideArithmetic.AddSigned192(relativeY, relativeY);
 58407            Signed192 endpointX = NarrowProven(
 58408                WideArithmetic.MultiplySigned192(
 58409                    Signed192.Signed(axisDirection.X.m_rawValue),
 58410                    Signed192.Signed(axisLength.m_rawValue)));
 58411            Signed192 endpointY = NarrowProven(
 58412                WideArithmetic.MultiplySigned192(
 58413                    Signed192.Signed(axisDirection.Y.m_rawValue),
 58414                    Signed192.Signed(axisLength.m_rawValue)));
 58415            directionX = WideArithmetic.MultiplySigned192(
 58416                WideArithmetic.SubtractSigned192(
 58417                    twiceRelativeX,
 58418                    endpointX),
 58419                ScaleSquared);
 58420            directionY = WideArithmetic.MultiplySigned192(
 58421                WideArithmetic.SubtractSigned192(
 58422                    twiceRelativeY,
 58423                    endpointY),
 58424                ScaleSquared);
 425        }
 79426        else if (WideArithmetic.AddSigned320(
 79427                     doubleProjection,
 79428                     axialThreshold).Sign < 0)
 429        {
 42430            Signed192 twiceRelativeX =
 42431                WideArithmetic.AddSigned192(relativeX, relativeX);
 42432            Signed192 twiceRelativeY =
 42433                WideArithmetic.AddSigned192(relativeY, relativeY);
 42434            Signed192 endpointX = NarrowProven(
 42435                WideArithmetic.MultiplySigned192(
 42436                    Signed192.Signed(axisDirection.X.m_rawValue),
 42437                    Signed192.Signed(axisLength.m_rawValue)));
 42438            Signed192 endpointY = NarrowProven(
 42439                WideArithmetic.MultiplySigned192(
 42440                    Signed192.Signed(axisDirection.Y.m_rawValue),
 42441                    Signed192.Signed(axisLength.m_rawValue)));
 42442            directionX = WideArithmetic.MultiplySigned192(
 42443                WideArithmetic.AddSigned192(
 42444                    twiceRelativeX,
 42445                    endpointX),
 42446                ScaleSquared);
 42447            directionY = WideArithmetic.MultiplySigned192(
 42448                WideArithmetic.AddSigned192(
 42449                    twiceRelativeY,
 42450                    endpointY),
 42451                ScaleSquared);
 452        }
 453        else
 454        {
 37455            Signed192 narrowProjection = NarrowProven(projection);
 37456            Signed320 residualX = WideArithmetic.SubtractSigned320(
 37457                WideArithmetic.MultiplySigned192(
 37458                    relativeX,
 37459                    ScaleSquared),
 37460                WideArithmetic.MultiplySigned192(
 37461                    Signed192.Signed(
 37462                        axisDirection.X.m_rawValue),
 37463                    narrowProjection));
 37464            Signed320 residualY = WideArithmetic.SubtractSigned320(
 37465                WideArithmetic.MultiplySigned192(
 37466                    relativeY,
 37467                    ScaleSquared),
 37468                WideArithmetic.MultiplySigned192(
 37469                    Signed192.Signed(
 37470                        axisDirection.Y.m_rawValue),
 37471                    narrowProjection));
 37472            directionX = WideArithmetic.AddSigned320(
 37473                residualX,
 37474                residualX);
 37475            directionY = WideArithmetic.AddSigned320(
 37476                residualY,
 37477                residualY);
 478        }
 479
 137480        squaredDistance = WideArithmetic.AddSigned576(
 137481            WideArithmetic.MultiplySigned320(directionX, directionX),
 137482            WideArithmetic.MultiplySigned320(directionY, directionY));
 137483        return WideNormalization.GetNormalized(directionX, directionY);
 484    }
 485
 486    private static Signed192 NarrowProven(Signed320 value)
 487    {
 1077488        _ = Signed192.TryNarrowSigned(value, out Signed192 result);
 1077489        return result;
 490    }
 491
 492    private static void GetSupportFeature(
 493        Vector2d center,
 494        Vector2d convexOrigin,
 495        Fixed64 convexRotation,
 496        ReadOnlySpan<Vector2d> convexOriginOffsets,
 497        Vector2d normal,
 498        bool axisFromEdge,
 499        out Vector2d featureStart,
 500        out Vector2d featureEnd)
 501    {
 24502        int minimumIndex = 0;
 24503        Signed192 minimum = GetRelativeProjection(
 24504            center,
 24505            convexOrigin,
 24506            convexRotation,
 24507            convexOriginOffsets[0],
 24508            normal);
 196509        for (int i = 1; i < convexOriginOffsets.Length; i++)
 510        {
 74511            Signed192 projection = GetRelativeProjection(
 74512                center,
 74513                convexOrigin,
 74514                convexRotation,
 74515                convexOriginOffsets[i],
 74516                normal);
 74517            if (WideArithmetic.SubtractSigned192(projection, minimum).Sign < 0)
 518            {
 9519                minimum = projection;
 9520                minimumIndex = i;
 521            }
 522        }
 523
 24524        featureStart = convexOriginOffsets[minimumIndex];
 24525        featureEnd = featureStart;
 24526        if (!axisFromEdge)
 1527            return;
 528
 23529        int previousIndex = minimumIndex;
 530        do
 531        {
 24532            previousIndex =
 24533                (previousIndex + convexOriginOffsets.Length - 1)
 24534                % convexOriginOffsets.Length;
 535        }
 24536        while (convexOriginOffsets[previousIndex] == featureStart);
 537
 23538        int nextIndex = minimumIndex;
 539        do
 540        {
 24541            nextIndex = (nextIndex + 1) % convexOriginOffsets.Length;
 542        }
 24543        while (convexOriginOffsets[nextIndex] == featureStart);
 544
 23545        Vector2d previous = convexOriginOffsets[previousIndex];
 23546        Vector2d next = convexOriginOffsets[nextIndex];
 23547        Vector2d previousDirection = WideConvex2dRelations.GetTransformedEdgeDirection(
 23548            convexRotation,
 23549            previous,
 23550            featureStart);
 23551        Vector2d nextDirection = WideConvex2dRelations.GetTransformedEdgeDirection(
 23552            convexRotation,
 23553            featureStart,
 23554            next);
 555
 23556        Fixed64 previousAlignment = Vector2d.Dot(previousDirection, normal).Abs();
 23557        Fixed64 nextAlignment = Vector2d.Dot(nextDirection, normal).Abs();
 23558        if (previousAlignment <= nextAlignment)
 8559            featureStart = previous;
 560        else
 15561            featureEnd = next;
 15562    }
 563
 564    private static bool TryKeepAxis(
 565        Vector2d center,
 566        Vector2d capsuleAxis,
 567        Fixed64 axisLength,
 568        Fixed64 radius,
 569        Vector2d convexOrigin,
 570        Fixed64 convexRotation,
 571        ReadOnlySpan<Vector2d> convexOriginOffsets,
 572        Vector2d axis,
 573        bool axisFromEdge,
 574        ref bool found,
 575        ref Signed576 bestDepth,
 576        ref Vector2d bestNormal,
 577        ref bool bestAxisFromEdge)
 578    {
 183579        GetRelativeProjectionRange(
 183580            center,
 183581            convexOrigin,
 183582            convexRotation,
 183583            convexOriginOffsets,
 183584            axis,
 183585            out Signed192 minimum,
 183586            out Signed192 maximum);
 183587        Signed192 axialAlignment = WideGeometry.GetDifferenceDotProduct2D(
 183588            capsuleAxis.X,
 183589            Fixed64.Zero,
 183590            capsuleAxis.Y,
 183591            Fixed64.Zero,
 183592            axis.X,
 183593            Fixed64.Zero,
 183594            axis.Y,
 183595            Fixed64.Zero);
 183596        if (axialAlignment.Sign < 0)
 59597            axialAlignment = WideArithmetic.SubtractSigned192(default, axialAlignment);
 598
 183599        Signed320 extentNumerator = WideArithmetic.AddSigned320(
 183600            WideArithmetic.MultiplySigned192(
 183601                axialAlignment,
 183602                Signed192.Signed(axisLength.m_rawValue)),
 183603            WideArithmetic.MultiplySigned192(
 183604                Signed192.Signed(radius.m_rawValue),
 183605                DoubleScaleSquared));
 183606        Signed320 minimumProjection = WideArithmetic.AddSigned320(
 183607            Signed320.ExtendValue(minimum),
 183608            Signed320.ExtendValue(minimum));
 183609        Signed320 maximumProjection = WideArithmetic.AddSigned320(
 183610            Signed320.ExtendValue(maximum),
 183611            Signed320.ExtendValue(maximum));
 183612        Signed576 positive = Signed576.ExtendValue(
 183613            WideArithmetic.SubtractSigned320(
 183614                extentNumerator,
 183615                minimumProjection));
 183616        Signed576 negative = Signed576.ExtendValue(
 183617            WideArithmetic.AddSigned320(
 183618                maximumProjection,
 183619                extentNumerator));
 183620        if (positive.Sign < 0 || negative.Sign < 0)
 15621            return false;
 622
 168623        bool usePositive = WideArithmetic.CompareNonNegative(positive, negative) <= 0;
 168624        Signed576 candidateDepth = usePositive ? positive : negative;
 168625        if (!found
 168626            || WideArithmetic.CompareNonNegative(candidateDepth, bestDepth) < 0)
 627        {
 58628            found = true;
 58629            bestDepth = candidateDepth;
 58630            bestNormal = usePositive ? axis : -axis;
 58631            bestAxisFromEdge = axisFromEdge;
 632        }
 633
 168634        return true;
 635    }
 636
 637    private static void GetRelativeProjectionRange(
 638        Vector2d center,
 639        Vector2d convexOrigin,
 640        Fixed64 convexRotation,
 641        ReadOnlySpan<Vector2d> convexOriginOffsets,
 642        Vector2d axis,
 643        out Signed192 minimum,
 644        out Signed192 maximum)
 645    {
 183646        minimum = GetRelativeProjection(
 183647            center,
 183648            convexOrigin,
 183649            convexRotation,
 183650            convexOriginOffsets[0],
 183651            axis);
 183652        maximum = minimum;
 1484653        for (int i = 1; i < convexOriginOffsets.Length; i++)
 654        {
 559655            Signed192 projection = GetRelativeProjection(
 559656                center,
 559657                convexOrigin,
 559658                convexRotation,
 559659                convexOriginOffsets[i],
 559660                axis);
 559661            if (WideArithmetic.SubtractSigned192(projection, minimum).Sign < 0)
 119662                minimum = projection;
 440663            else if (WideArithmetic.SubtractSigned192(projection, maximum).Sign > 0)
 97664                maximum = projection;
 665        }
 183666    }
 667
 668    private static Signed192 GetRelativeProjection(
 669        Vector2d center,
 670        Vector2d pointOrigin,
 671        Fixed64 pointRotation,
 672        Vector2d pointOriginOffset,
 673        Vector2d axis)
 674    {
 840675        WideConvex2dRelations.GetRelativePointNumerators(
 840676            pointOrigin,
 840677            pointRotation,
 840678            pointOriginOffset,
 840679            center,
 840680            out Signed192 differenceX,
 840681            out Signed192 differenceY);
 840682        Signed320 projection = WideArithmetic.AddSigned320(
 840683            WideArithmetic.MultiplySigned192(
 840684                differenceX,
 840685                Signed192.Signed(axis.X.m_rawValue)),
 840686            WideArithmetic.MultiplySigned192(
 840687                differenceY,
 840688                Signed192.Signed(axis.Y.m_rawValue)));
 840689        return NarrowProven(projection);
 690    }
 691
 692}

Methods/Properties

.cctor()
TryGetMinimumTranslation(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d&,FixedMathSharp.Fixed64&)
TryGetMinimumTranslation(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d&,FixedMathSharp.Fixed64&)
TryGetContacts(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,System.Span`1<FixedMathSharp.Geometry.FixedPointAnchor2d>,System.Span`1<FixedMathSharp.Geometry.FixedPointAnchor2d>,System.Int32&,FixedMathSharp.Vector2d&,FixedMathSharp.Fixed64&,System.Boolean&)
GetCenteredCapsuleSideAnchor(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
TryGetMinimumTranslation(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d&,FixedMathSharp.Fixed64&,System.Boolean&,System.Boolean&)
GetClosestVertexAxis(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>)
GetDirectionFromCenteredAxis(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Signed576&)
NarrowProven(FixedMathSharp.Signed320)
GetSupportFeature(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,System.Boolean,FixedMathSharp.Vector2d&,FixedMathSharp.Vector2d&)
TryKeepAxis(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,System.Boolean,System.Boolean&,FixedMathSharp.Signed576&,FixedMathSharp.Vector2d&,System.Boolean&)
GetRelativeProjectionRange(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,FixedMathSharp.Signed192&,FixedMathSharp.Signed192&)
GetRelativeProjection(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)