< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_HasValue()100%11100%
.ctor(...)100%22100%
CompareRootRatio(...)100%44100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// CurvedPrismContactValue.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>Borrowed native minimum; comparisons never retain or round its wide value.</summary>
 13internal readonly ref struct CurvedPrismContactValue
 14{
 15    private readonly ConvexContactCandidate _analytic;
 16    private readonly CurvedPrismRimContacts.Selection _rim;
 17    private readonly bool _hasValue;
 2218    internal bool HasValue => _hasValue;
 19    internal CurvedPrismContactValue(ConvexContactCandidate analytic, bool hasAnalytic, in CurvedPrismRimContacts.Select
 25620    { _analytic = analytic; _rim = rim; _hasValue = hasAnalytic || rim.HasValue; }
 21
 22    // Compares N*sqrt(metric)/(D*|scale|) with the native nonnegative gap.
 23    // Squaring preserves order. Keep the CQ denominator instead of multiplying
 24    // by its conjugate: the existing ratio owner already compares two fields.
 25    internal int CompareRootRatio(in CurvedPrismContactGeometry geometry, scoped ContactQuadratic numerator,
 26        scoped ContactQuadratic denominator, scoped ReadOnlySpan<ulong> root, Signed832 metric, Signed320 scale)
 27    {
 1428        if (!HasValue) return -1;
 3029        Span<ulong> metricWords = stackalloc ulong[13], scaleWords = stackalloc ulong[5], squaredScale = stackalloc ulon
 1030        WideArithmetic.GetMagnitude(metric, metricWords);
 1031        WideArithmetic.GetMagnitude(scale, out scaleWords[4], out scaleWords[3], out scaleWords[2], out scaleWords[1], o
 1032        WideArithmetic.MultiplyMagnitudes(scaleWords, scaleWords, squaredScale);
 1033        int words = 2 * Math.Max(ContactQuadratic.ActiveWords(numerator), ContactQuadratic.ActiveWords(denominator))
 1034            + WideArithmetic.GetActiveMagnitudeLength(root)
 1035            + Math.Max(WideArithmetic.GetActiveMagnitudeLength(metricWords), WideArithmetic.GetActiveMagnitudeLength(squ
 2036        Span<ulong> fields = stackalloc ulong[6 * words]; Span<int> signs = stackalloc int[6];
 2037        var n = ContactQuadratic.At(fields, signs, 0, words); var d = ContactQuadratic.At(fields, signs, 1, words);
 1038        var term = ContactQuadratic.At(fields, signs, 2, words);
 3039        ContactQuadratic.Multiply(numerator, numerator, root, n); ContactQuadratic.Scale(n, metricWords, 1, term); term.
 3040        ContactQuadratic.Multiply(denominator, denominator, root, d); ContactQuadratic.Scale(d, squaredScale, 1, term); 
 1241        if (_rim.HasValue) return -CurvedPrismRimContacts.CompareSquaredDepth(geometry, _rim, n, d, root);
 842        int analyticWords = Math.Max(1, Math.Max(WideArithmetic.GetActiveMagnitudeLength(_analytic.GapDenominator),
 843            Math.Max(WideArithmetic.GetActiveMagnitudeLength(_analytic.GapRational), WideArithmetic.GetActiveMagnitudeLe
 1644        Span<ulong> analyticValues = stackalloc ulong[4 * analyticWords]; Span<int> analyticSigns = stackalloc int[4];
 1645        var a = ContactQuadratic.At(analyticValues, analyticSigns, 0, analyticWords); var b = ContactQuadratic.At(analyt
 1646        a.Clear(); b.Clear();
 847        _analytic.GapRational[..WideArithmetic.GetActiveMagnitudeLength(_analytic.GapRational)].CopyTo(a.Rational);
 848        _analytic.GapRadical[..WideArithmetic.GetActiveMagnitudeLength(_analytic.GapRadical)].CopyTo(a.Radical);
 1649        a.Signs[0] = _analytic.GapRationalSign; a.Signs[1] = _analytic.GapRadicalSign;
 1650        _analytic.GapDenominator[..WideArithmetic.GetActiveMagnitudeLength(_analytic.GapDenominator)].CopyTo(b.Rational)
 851        return ContactQuadratic.CompareRatios(n, d, root, a, b, _analytic.GapRadicand);
 52    }
 53}