< Summary

Information
Class: FixedMathSharp.Geometry.WideTriangleConeIntersection
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/FiniteAxis/WideTriangleConeIntersection.cs
Line coverage
100%
Covered lines: 434
Uncovered lines: 0
Coverable lines: 434
Total lines: 753
Line coverage: 100%
Branch coverage
100%
Covered branches: 64
Total branches: 64
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/Wide/FiniteAxis/WideTriangleConeIntersection.cs

#LineLine coverage
 1//=======================================================================
 2// WideTriangleConeIntersection.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
 8namespace FixedMathSharp.Geometry;
 9
 10/// <summary>
 11/// Owns exact full-domain triangle-face reduction against finite cones.
 12/// </summary>
 13internal static class WideTriangleConeIntersection
 14{
 115    private static readonly Signed192 Scale = Signed192.Signed(Fixed64.One.m_rawValue);
 116    private static readonly Signed192 MaximumParameter = Signed192.Signed(Fixed64.MaxValue.m_rawValue);
 17
 18    internal static bool TryGetFaceMinimumAxialPoint(
 19        FixedTriangle triangle,
 20        Signed192 normalX,
 21        Signed192 normalY,
 22        Signed192 normalZ,
 23        Signed320 normalSquared,
 24        Vector3d apex,
 25        Vector3d axisDirection,
 26        Fixed64 height,
 27        Fixed64 baseRadius,
 28        bool hasEdgeIntersection,
 29        out Vector3d point,
 30        out Fixed64 axialParameter)
 31    {
 2432        Signed192 q = GetDot(axisDirection, Vector3d.Zero, axisDirection, Vector3d.Zero);
 2433        Signed320 bWide = GetDot(normalX, normalY, normalZ, axisDirection, Vector3d.Zero);
 2434        Signed192 b = Signed192.NarrowValue(bWide);
 2435        Signed320 c = GetDot(normalX, normalY, normalZ, triangle.A, apex);
 2436        Signed576 p = WideArithmetic.SubtractSigned576(
 2437            WideArithmetic.MultiplySigned576(Signed576.ExtendValue(normalSquared), q),
 2438            WideArithmetic.MultiplySigned320(bWide, bWide));
 39
 2440        if (p.IsZero)
 841            return TryGetPerpendicularPlanePoint(
 842                triangle,
 843                normalX,
 844                normalY,
 845                normalZ,
 846                apex,
 847                axisDirection,
 848                height,
 849                b,
 850                c,
 851                hasEdgeIntersection,
 852                out point,
 853                out axialParameter);
 54
 1655        Signed320 vX = GetRadialNormalComponent(q, normalX, b, axisDirection.X);
 1656        Signed320 vY = GetRadialNormalComponent(q, normalY, b, axisDirection.Y);
 1657        Signed320 vZ = GetRadialNormalComponent(q, normalZ, b, axisDirection.Z);
 1658        Signed576 wX = GetStationaryDirectionComponent(p, axisDirection.X, bWide, vX);
 1659        Signed576 wY = GetStationaryDirectionComponent(p, axisDirection.Y, bWide, vY);
 1660        Signed576 wZ = GetStationaryDirectionComponent(p, axisDirection.Z, bWide, vZ);
 61
 1662        CreatePolynomial(
 1663            q,
 1664            bWide,
 1665            c,
 1666            p,
 1667            height,
 1668            baseRadius,
 1669            out Signed576 coefficient,
 1670            out Signed576 projection,
 1671            out Signed576 constant);
 1672        if (!TryGetMinimumScaledParameter(
 1673                coefficient,
 1674                projection,
 1675                constant,
 1676                b,
 1677                c,
 1678                height,
 1679                out Fixed64 entry))
 80        {
 281            point = default;
 282            axialParameter = default;
 283            return false;
 84        }
 85
 86        bool keepFace;
 1487        if (!hasEdgeIntersection)
 88        {
 989            keepFace = ContainsNoEdgeProbe(
 990                triangle,
 991                normalX,
 992                normalY,
 993                normalZ,
 994                normalSquared,
 995                apex,
 996                axisDirection,
 997                height,
 998                q,
 999                b,
 9100                bWide,
 9101                c,
 9102                p,
 9103                coefficient,
 9104                projection,
 9105                constant);
 106        }
 107        else
 108        {
 5109            GetLowerRootLatticeBracket(
 5110                coefficient,
 5111                projection,
 5112                constant,
 5113                entry,
 5114                out Fixed64 lowerParameter,
 5115                out Fixed64 upperParameter);
 5116            keepFace = ContainsStationaryPoint(
 5117                triangle,
 5118                normalX,
 5119                normalY,
 5120                normalZ,
 5121                normalSquared,
 5122                apex,
 5123                axisDirection,
 5124                height,
 5125                q,
 5126                bWide,
 5127                c,
 5128                p,
 5129                lowerParameter)
 5130                && (upperParameter == lowerParameter
 5131                    || ContainsStationaryPoint(
 5132                        triangle,
 5133                        normalX,
 5134                        normalY,
 5135                        normalZ,
 5136                        normalSquared,
 5137                        apex,
 5138                        axisDirection,
 5139                        height,
 5140                        q,
 5141                        bWide,
 5142                        c,
 5143                        p,
 5144                        upperParameter));
 145        }
 14146        if (!keepFace)
 147        {
 4148            point = default;
 4149            axialParameter = default;
 4150            return false;
 151        }
 152
 10153        point = new Vector3d(
 10154            GetWitnessCoordinate(apex.X, vX, wX, c, p, height, entry),
 10155            GetWitnessCoordinate(apex.Y, vY, wY, c, p, height, entry),
 10156            GetWitnessCoordinate(apex.Z, vZ, wZ, c, p, height, entry));
 10157        axialParameter = Fixed64.GetSignedRawRatio(
 10158            WideArithmetic.MultiplySigned192(
 10159                Signed192.Signed(height.m_rawValue),
 10160                Signed192.Signed(entry.m_rawValue)),
 10161            MaximumParameter);
 10162        return true;
 163    }
 164
 165    private static bool TryGetMinimumScaledParameter(
 166        Signed576 coefficient,
 167        Signed576 projection,
 168        Signed576 constant,
 169        Signed192 b,
 170        Signed320 c,
 171        Fixed64 height,
 172        out Fixed64 entry)
 173    {
 16174        if (FitsSigned832Product(projection, projection)
 16175            && FitsSigned832Product(coefficient, constant))
 176        {
 12177            return WideFiniteConeIntersection.TrySolveUnitPolynomial(
 12178                coefficient,
 12179                projection,
 12180                constant,
 12181                Fixed64.MaxValue,
 12182                out entry,
 12183                out _);
 184        }
 185
 4186        if (!TryGetContainedUpperBound(
 4187                coefficient,
 4188                projection,
 4189                constant,
 4190                b,
 4191                c,
 4192                height,
 4193                out Signed576 upperNumerator,
 4194                out Signed576 upperDenominator))
 195        {
 1196            entry = default;
 1197            return false;
 198        }
 199
 3200        ulong low = 0UL;
 3201        ulong high = (ulong)Fixed64.MaxValue.m_rawValue;
 3202        Signed192 midpointDenominator = new(0UL, 0UL, high << 1);
 192203        while (low < high)
 204        {
 189205            ulong candidate = low + ((high - low) >> 1);
 189206            Signed192 midpointNumerator = new(0UL, 0UL, (candidate << 1) | 1UL);
 189207            int upperComparison = CompareRationals(
 189208                midpointNumerator,
 189209                midpointDenominator,
 189210                upperNumerator,
 189211                upperDenominator);
 189212            int polynomialSign = upperComparison > 0
 189213                ? -1
 189214                : WideFiniteConeIntersection.GetPolynomialSignAtRationalParameter(
 189215                    coefficient,
 189216                    projection,
 189217                    constant,
 189218                    midpointNumerator,
 189219                    midpointDenominator);
 189220            bool midpointPrecedesRoot = polynomialSign > 0
 189221                || (polynomialSign == 0 && (candidate & 1UL) != 0UL);
 189222            if (midpointPrecedesRoot)
 56223                low = candidate + 1UL;
 224            else
 133225                high = candidate;
 226        }
 227
 3228        entry = Fixed64.FromRaw((long)low);
 3229        return true;
 230    }
 231
 232    private static bool TryGetContainedUpperBound(
 233        Signed576 coefficient,
 234        Signed576 projection,
 235        Signed576 constant,
 236        Signed192 b,
 237        Signed320 c,
 238        Fixed64 height,
 239        out Signed576 numerator,
 240        out Signed576 denominator)
 241    {
 4242        if (TryGetNonNegativeAxisPlaneRatio(
 4243                b,
 4244                c,
 4245                height,
 4246                out Signed192 axisDenominator,
 4247                out Signed320 axisNumerator))
 248        {
 1249            numerator = WideArithmetic.MultiplySigned576(
 1250                Signed576.ExtendValue(axisNumerator),
 1251                Scale);
 1252            denominator = Signed576.ExtendValue(
 1253                WideArithmetic.MultiplySigned192(
 1254                    axisDenominator,
 1255                    Signed192.Signed(height.m_rawValue)));
 1256            return true;
 257        }
 258
 259        // Without an in-range axis crossing, the absolute plane distance is
 260        // linear on [0, 1]; any admitted interval therefore reaches the cap.
 3261        if (WideFiniteConeIntersection.GetPolynomialSignAtScaledParameter(
 3262                coefficient,
 3263                projection,
 3264                constant,
 3265                Fixed64.One,
 3266                Fixed64.One) > 0)
 267        {
 1268            numerator = default;
 1269            denominator = default;
 1270            return false;
 271        }
 272
 2273        numerator = Signed576.ExtendValue(
 2274            Signed320.ExtendValue(Signed192.Signed(1L)));
 2275        denominator = numerator;
 2276        return true;
 277    }
 278
 279    private static int CompareRationals(
 280        Signed192 leftNumerator,
 281        Signed192 leftDenominator,
 282        Signed576 rightNumerator,
 283        Signed576 rightDenominator) =>
 189284        WideArithmetic.CompareNonNegative(
 189285            WideArithmetic.MultiplySigned576(rightDenominator, leftNumerator),
 189286            WideArithmetic.MultiplySigned576(rightNumerator, leftDenominator));
 287
 288    private static bool FitsSigned832Product(Signed576 left, Signed576 right)
 289    {
 31290        int leftBits = GetMagnitudeBitLength(left);
 31291        int rightBits = GetMagnitudeBitLength(right);
 31292        return leftBits == 0 || rightBits == 0 || leftBits + rightBits <= 830;
 293    }
 294
 295    private static int GetMagnitudeBitLength(Signed576 value)
 296    {
 62297        System.Span<ulong> magnitude = stackalloc ulong[9];
 62298        WideArithmetic.GetMagnitude(value, magnitude);
 62299        return WideArithmetic.GetMagnitudeBitLength(magnitude);
 300    }
 301
 302    private static void CreatePolynomial(
 303        Signed192 q,
 304        Signed320 b,
 305        Signed320 c,
 306        Signed576 p,
 307        Fixed64 height,
 308        Fixed64 baseRadius,
 309        out Signed576 coefficient,
 310        out Signed576 projection,
 311        out Signed576 constant)
 312    {
 16313        Signed192 heightRaw = Signed192.Signed(height.m_rawValue);
 16314        Signed192 radiusRaw = Signed192.Signed(baseRadius.m_rawValue);
 16315        Signed576 bSquared = WideArithmetic.MultiplySigned320(b, b);
 16316        Signed576 firstCoefficient = WideArithmetic.MultiplySigned576(bSquared, q, heightRaw, heightRaw);
 16317        Signed576 secondCoefficient = WideArithmetic.MultiplySigned576(p, radiusRaw, radiusRaw, Scale, Scale);
 16318        coefficient = WideArithmetic.SubtractSigned576(firstCoefficient, secondCoefficient);
 319
 16320        Signed576 bc = WideArithmetic.MultiplySigned320(b, c);
 16321        projection = WideArithmetic.SubtractSigned576(
 16322            default,
 16323            WideArithmetic.MultiplySigned576(bc, q, Scale, heightRaw));
 16324        constant = WideArithmetic.MultiplySigned576(WideArithmetic.MultiplySigned320(c, c), q, Scale, Scale);
 16325    }
 326
 327    private static void GetLowerRootLatticeBracket(
 328        Signed576 coefficient,
 329        Signed576 projection,
 330        Signed576 constant,
 331        Fixed64 entry,
 332        out Fixed64 lowerParameter,
 333        out Fixed64 upperParameter)
 334    {
 5335        int entrySign = WideFiniteConeIntersection.GetPolynomialSignAtScaledParameter(
 5336                coefficient,
 5337                projection,
 5338                constant,
 5339                entry,
 5340                Fixed64.MaxValue);
 5341        if (entrySign == 0)
 342        {
 1343            lowerParameter = entry;
 1344            upperParameter = entry;
 1345            return;
 346        }
 347
 4348        if (entrySign > 0)
 349        {
 3350            lowerParameter = entry;
 3351            upperParameter = Fixed64.FromRaw(entry.m_rawValue + 1L);
 3352            return;
 353        }
 354
 1355        upperParameter = entry;
 1356        lowerParameter = Fixed64.FromRaw(entry.m_rawValue - 1L);
 1357    }
 358
 359    private static bool ContainsNoEdgeProbe(
 360        FixedTriangle triangle,
 361        Signed192 normalX,
 362        Signed192 normalY,
 363        Signed192 normalZ,
 364        Signed320 normalSquared,
 365        Vector3d apex,
 366        Vector3d axisDirection,
 367        Fixed64 height,
 368        Signed192 q,
 369        Signed192 b,
 370        Signed320 bWide,
 371        Signed320 c,
 372        Signed576 p,
 373        Signed576 coefficient,
 374        Signed576 projection,
 375        Signed576 constant)
 376    {
 9377        if (TryGetNonNegativeAxisPlaneRatio(b, c, height, out Signed192 denominator, out Signed320 numerator))
 378        {
 2379            return ContainsAxisPlanePoint(
 2380                triangle,
 2381                normalX,
 2382                normalY,
 2383                normalZ,
 2384                apex,
 2385                axisDirection,
 2386                denominator,
 2387                numerator);
 388        }
 389
 7390        return ContainsStationaryPoint(
 7391            triangle,
 7392            normalX,
 7393            normalY,
 7394            normalZ,
 7395            normalSquared,
 7396            apex,
 7397            axisDirection,
 7398            height,
 7399            q,
 7400            bWide,
 7401            c,
 7402            p,
 7403            Fixed64.MaxValue);
 404    }
 405
 406    private static bool TryGetPerpendicularPlanePoint(
 407        FixedTriangle triangle,
 408        Signed192 normalX,
 409        Signed192 normalY,
 410        Signed192 normalZ,
 411        Vector3d apex,
 412        Vector3d axisDirection,
 413        Fixed64 height,
 414        Signed192 b,
 415        Signed320 c,
 416        bool hasEdgeIntersection,
 417        out Vector3d point,
 418        out Fixed64 axialParameter)
 419    {
 8420        if (hasEdgeIntersection
 8421            || !TryGetNonNegativeAxisPlaneRatio(b, c, height, out Signed192 denominator, out Signed320 numerator)
 8422            || !ContainsAxisPlanePoint(
 8423                triangle,
 8424                normalX,
 8425                normalY,
 8426                normalZ,
 8427                apex,
 8428                axisDirection,
 8429                denominator,
 8430                numerator))
 431        {
 6432            point = default;
 6433            axialParameter = default;
 6434            return false;
 435        }
 436
 2437        point = new Vector3d(
 2438            GetAxisPlaneCoordinate(apex.X, axisDirection.X, denominator, numerator),
 2439            GetAxisPlaneCoordinate(apex.Y, axisDirection.Y, denominator, numerator),
 2440            GetAxisPlaneCoordinate(apex.Z, axisDirection.Z, denominator, numerator));
 2441        Signed576 axialNumerator = WideArithmetic.MultiplySigned576(
 2442            Signed576.ExtendValue(numerator),
 2443            Scale);
 2444        _ = Fixed64.TryGetSignedRawRatio(
 2445            axialNumerator,
 2446            Signed576.ExtendValue(Signed320.ExtendValue(denominator)),
 2447            out axialParameter);
 2448        return true;
 449    }
 450
 451    private static bool TryGetNonNegativeAxisPlaneRatio(
 452        Signed192 b,
 453        Signed320 c,
 454        Fixed64 height,
 455        out Signed192 denominator,
 456        out Signed320 numerator)
 457    {
 20458        if (b.Sign == 0)
 459        {
 10460            denominator = default;
 10461            numerator = default;
 10462            return false;
 463        }
 464
 10465        denominator = b.Sign > 0
 10466            ? b
 10467            : WideArithmetic.SubtractSigned192(default, b);
 10468        numerator = b.Sign > 0
 10469            ? c
 10470            : WideArithmetic.SubtractSigned320(default, c);
 10471        if (numerator.Sign < 0)
 1472            return false;
 473
 9474        Signed576 scaledNumerator = WideArithmetic.MultiplySigned576(
 9475            Signed576.ExtendValue(numerator),
 9476            Scale);
 9477        Signed576 maximumNumerator = Signed576.ExtendValue(
 9478            WideArithmetic.MultiplySigned192(
 9479                denominator,
 9480                Signed192.Signed(height.m_rawValue)));
 9481        return WideArithmetic.CompareNonNegative(scaledNumerator, maximumNumerator) <= 0;
 482    }
 483
 484    private static bool ContainsAxisPlanePoint(
 485        FixedTriangle triangle,
 486        Signed192 normalX,
 487        Signed192 normalY,
 488        Signed192 normalZ,
 489        Vector3d apex,
 490        Vector3d axisDirection,
 491        Signed192 denominator,
 492        Signed320 numerator) =>
 7493        GetAxisPlaneHalfspaceSign(triangle.A, triangle.B, normalX, normalY, normalZ, apex, axisDirection, denominator, n
 7494        && GetAxisPlaneHalfspaceSign(triangle.B, triangle.C, normalX, normalY, normalZ, apex, axisDirection, denominator
 7495        && GetAxisPlaneHalfspaceSign(triangle.C, triangle.A, normalX, normalY, normalZ, apex, axisDirection, denominator
 496
 497    private static int GetAxisPlaneHalfspaceSign(
 498        Vector3d edgeStart,
 499        Vector3d edgeEnd,
 500        Signed192 normalX,
 501        Signed192 normalY,
 502        Signed192 normalZ,
 503        Vector3d apex,
 504        Vector3d axisDirection,
 505        Signed192 denominator,
 506        Signed320 numerator)
 507    {
 18508        GetEdgeProducts(
 18509            edgeStart,
 18510            edgeEnd,
 18511            normalX,
 18512            normalY,
 18513            normalZ,
 18514            apex,
 18515            axisDirection,
 18516            out Signed320 hO,
 18517            out Signed320 l);
 18518        Signed576 first = WideArithmetic.MultiplySigned576(
 18519            Signed576.ExtendValue(hO),
 18520            denominator);
 18521        Signed576 second = WideArithmetic.MultiplySigned320(numerator, l);
 18522        return WideArithmetic.AddSigned576(first, second).Sign;
 523    }
 524
 525    private static bool ContainsStationaryPoint(
 526        FixedTriangle triangle,
 527        Signed192 normalX,
 528        Signed192 normalY,
 529        Signed192 normalZ,
 530        Signed320 normalSquared,
 531        Vector3d apex,
 532        Vector3d axisDirection,
 533        Fixed64 height,
 534        Signed192 q,
 535        Signed320 b,
 536        Signed320 c,
 537        Signed576 p,
 538        Fixed64 scaledParameter) =>
 14539        GetStationaryHalfspaceSign(triangle.A, triangle.B, normalX, normalY, normalZ, normalSquared, apex, axisDirection
 14540        && GetStationaryHalfspaceSign(triangle.B, triangle.C, normalX, normalY, normalZ, normalSquared, apex, axisDirect
 14541        && GetStationaryHalfspaceSign(triangle.C, triangle.A, normalX, normalY, normalZ, normalSquared, apex, axisDirect
 542
 543    private static int GetStationaryHalfspaceSign(
 544        Vector3d edgeStart,
 545        Vector3d edgeEnd,
 546        Signed192 normalX,
 547        Signed192 normalY,
 548        Signed192 normalZ,
 549        Signed320 normalSquared,
 550        Vector3d apex,
 551        Vector3d axisDirection,
 552        Fixed64 height,
 553        Signed192 q,
 554        Signed320 b,
 555        Signed320 c,
 556        Signed576 p,
 557        Fixed64 scaledParameter)
 558    {
 34559        GetEdgeProducts(
 34560            edgeStart,
 34561            edgeEnd,
 34562            normalX,
 34563            normalY,
 34564            normalZ,
 34565            apex,
 34566            axisDirection,
 34567            out Signed320 hO,
 34568            out Signed320 l);
 34569        Signed192 scaleParameter = Signed192.Signed(Fixed64.MaxValue.m_rawValue);
 34570        Signed192 parameter = Signed192.Signed(scaledParameter.m_rawValue);
 34571        Signed192 heightRaw = Signed192.Signed(height.m_rawValue);
 572
 34573        Signed576 pScale = WideArithmetic.MultiplySigned576(p, scaleParameter, Scale);
 34574        Signed704 first = WideArithmetic.MultiplySigned576ToSigned704(pScale, hO);
 575
 34576        Signed576 negativeBC = WideArithmetic.SubtractSigned576(
 34577            default,
 34578            WideArithmetic.MultiplySigned320(b, c));
 34579        Signed704 second = WideArithmetic.MultiplySigned576ToSigned704(
 34580            WideArithmetic.MultiplySigned576(negativeBC, scaleParameter, Scale),
 34581            l);
 582
 34583        Signed576 normalEdge = WideArithmetic.MultiplySigned320(normalSquared, l);
 34584        Signed192 qHeight = Signed192.NarrowValue(
 34585            WideArithmetic.MultiplySigned192(q, heightRaw));
 34586        Signed320 qHeightParameter = WideArithmetic.MultiplySigned192(qHeight, parameter);
 34587        Signed704 third = WideArithmetic.MultiplySigned576ToSigned704(
 34588            normalEdge,
 34589            qHeightParameter);
 34590        return WideArithmetic.AddSigned704(
 34591            WideArithmetic.AddSigned704(first, second),
 34592            third).Sign;
 593    }
 594
 595    private static void GetEdgeProducts(
 596        Vector3d edgeStart,
 597        Vector3d edgeEnd,
 598        Signed192 normalX,
 599        Signed192 normalY,
 600        Signed192 normalZ,
 601        Vector3d apex,
 602        Vector3d axisDirection,
 603        out Signed320 hO,
 604        out Signed320 l)
 605    {
 52606        Signed192 edgeX = WideArithmetic.Difference(edgeEnd.X, edgeStart.X);
 52607        Signed192 edgeY = WideArithmetic.Difference(edgeEnd.Y, edgeStart.Y);
 52608        Signed192 edgeZ = WideArithmetic.Difference(edgeEnd.Z, edgeStart.Z);
 52609        GetCross(
 52610            edgeX,
 52611            edgeY,
 52612            edgeZ,
 52613            WideArithmetic.Difference(apex.X, edgeStart.X),
 52614            WideArithmetic.Difference(apex.Y, edgeStart.Y),
 52615            WideArithmetic.Difference(apex.Z, edgeStart.Z),
 52616            out Signed192 originCrossX,
 52617            out Signed192 originCrossY,
 52618            out Signed192 originCrossZ);
 52619        GetCross(
 52620            edgeX,
 52621            edgeY,
 52622            edgeZ,
 52623            Signed192.Signed(axisDirection.X.m_rawValue),
 52624            Signed192.Signed(axisDirection.Y.m_rawValue),
 52625            Signed192.Signed(axisDirection.Z.m_rawValue),
 52626            out Signed192 axisCrossX,
 52627            out Signed192 axisCrossY,
 52628            out Signed192 axisCrossZ);
 52629        hO = GetDot(normalX, normalY, normalZ, originCrossX, originCrossY, originCrossZ);
 52630        l = GetDot(normalX, normalY, normalZ, axisCrossX, axisCrossY, axisCrossZ);
 52631    }
 632
 633    private static Fixed64 GetWitnessCoordinate(
 634        Fixed64 apexCoordinate,
 635        Signed320 v,
 636        Signed576 w,
 637        Signed320 c,
 638        Signed576 p,
 639        Fixed64 height,
 640        Fixed64 scaledParameter)
 641    {
 30642        Signed576 baseValue = WideArithmetic.AddSigned576(
 30643            WideArithmetic.MultiplySigned576(
 30644                p,
 30645                Signed192.Signed(apexCoordinate.m_rawValue)),
 30646            WideArithmetic.MultiplySigned320(c, v));
 30647        Signed576 first = WideArithmetic.MultiplySigned576(baseValue, MaximumParameter, Scale);
 30648        Signed576 second = WideArithmetic.MultiplySigned576(
 30649            w,
 30650            Signed192.Signed(scaledParameter.m_rawValue),
 30651            Signed192.Signed(height.m_rawValue));
 30652        Signed576 denominator = WideArithmetic.MultiplySigned576(p, MaximumParameter, Scale);
 30653        _ = Fixed64.TryGetSignedRawRatio(
 30654            WideArithmetic.AddSigned576(first, second),
 30655            denominator,
 30656            out Fixed64 coordinate);
 30657        return coordinate;
 658    }
 659
 660    private static Fixed64 GetAxisPlaneCoordinate(
 661        Fixed64 apexCoordinate,
 662        Fixed64 axisCoordinate,
 663        Signed192 denominator,
 664        Signed320 numerator)
 665    {
 6666        Signed576 first = Signed576.ExtendValue(
 6667            WideArithmetic.MultiplySigned192(
 6668                denominator,
 6669                Signed192.Signed(apexCoordinate.m_rawValue)));
 6670        Signed576 second = WideArithmetic.MultiplySigned576(
 6671            Signed576.ExtendValue(numerator),
 6672            Signed192.Signed(axisCoordinate.m_rawValue));
 6673        _ = Fixed64.TryGetSignedRawRatio(
 6674            WideArithmetic.AddSigned576(first, second),
 6675            Signed576.ExtendValue(Signed320.ExtendValue(denominator)),
 6676            out Fixed64 coordinate);
 6677        return coordinate;
 678    }
 679
 680    private static Signed320 GetRadialNormalComponent(
 681        Signed192 q,
 682        Signed192 normal,
 683        Signed192 b,
 684        Fixed64 axis) =>
 48685        WideArithmetic.SubtractSigned320(
 48686            WideArithmetic.MultiplySigned192(q, normal),
 48687            WideArithmetic.MultiplySigned192(
 48688                b,
 48689                Signed192.Signed(axis.m_rawValue)));
 690
 691    private static Signed576 GetStationaryDirectionComponent(
 692        Signed576 p,
 693        Fixed64 axis,
 694        Signed320 b,
 695        Signed320 v) =>
 48696        WideArithmetic.SubtractSigned576(
 48697            WideArithmetic.MultiplySigned576(
 48698                p,
 48699                Signed192.Signed(axis.m_rawValue)),
 48700            WideArithmetic.MultiplySigned320(b, v));
 701
 702    private static Signed192 GetDot(
 703        Vector3d leftEnd,
 704        Vector3d leftStart,
 705        Vector3d rightEnd,
 706        Vector3d rightStart) =>
 24707        WideGeometry.GetDifferenceDotProduct3D(
 24708            leftEnd.X, leftStart.X, leftEnd.Y, leftStart.Y, leftEnd.Z, leftStart.Z,
 24709            rightEnd.X, rightStart.X, rightEnd.Y, rightStart.Y, rightEnd.Z, rightStart.Z);
 710
 711    private static Signed320 GetDot(
 712        Signed192 leftX,
 713        Signed192 leftY,
 714        Signed192 leftZ,
 715        Vector3d rightEnd,
 716        Vector3d rightStart) =>
 48717        GetDot(
 48718            leftX,
 48719            leftY,
 48720            leftZ,
 48721            WideArithmetic.Difference(rightEnd.X, rightStart.X),
 48722            WideArithmetic.Difference(rightEnd.Y, rightStart.Y),
 48723            WideArithmetic.Difference(rightEnd.Z, rightStart.Z));
 724
 725    private static Signed320 GetDot(
 726        Signed192 leftX,
 727        Signed192 leftY,
 728        Signed192 leftZ,
 729        Signed192 rightX,
 730        Signed192 rightY,
 731        Signed192 rightZ) =>
 152732        WideArithmetic.AddSigned320(
 152733            WideArithmetic.AddSigned320(
 152734                WideArithmetic.MultiplySigned192(leftX, rightX),
 152735                WideArithmetic.MultiplySigned192(leftY, rightY)),
 152736            WideArithmetic.MultiplySigned192(leftZ, rightZ));
 737
 738    private static void GetCross(
 739        Signed192 leftX,
 740        Signed192 leftY,
 741        Signed192 leftZ,
 742        Signed192 rightX,
 743        Signed192 rightY,
 744        Signed192 rightZ,
 745        out Signed192 x,
 746        out Signed192 y,
 747        out Signed192 z)
 748    {
 104749        x = Signed192.NarrowValue(WideArithmetic.MultiplySubtract(leftY, rightZ, leftZ, rightY));
 104750        y = Signed192.NarrowValue(WideArithmetic.MultiplySubtract(leftZ, rightX, leftX, rightZ));
 104751        z = Signed192.NarrowValue(WideArithmetic.MultiplySubtract(leftX, rightY, leftY, rightX));
 104752    }
 753}

Methods/Properties

.cctor()
TryGetFaceMinimumAxialPoint(FixedMathSharp.Geometry.FixedTriangle,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,System.Boolean,FixedMathSharp.Vector3d&,FixedMathSharp.Fixed64&)
TryGetMinimumScaledParameter(FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64&)
TryGetContainedUpperBound(FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Fixed64,FixedMathSharp.Signed576&,FixedMathSharp.Signed576&)
CompareRationals(FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed576,FixedMathSharp.Signed576)
FitsSigned832Product(FixedMathSharp.Signed576,FixedMathSharp.Signed576)
GetMagnitudeBitLength(FixedMathSharp.Signed576)
CreatePolynomial(FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Signed576&,FixedMathSharp.Signed576&,FixedMathSharp.Signed576&)
GetLowerRootLatticeBracket(FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64&,FixedMathSharp.Fixed64&)
ContainsNoEdgeProbe(FixedMathSharp.Geometry.FixedTriangle,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed576,FixedMathSharp.Signed576)
TryGetPerpendicularPlanePoint(FixedMathSharp.Geometry.FixedTriangle,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Signed192,FixedMathSharp.Signed320,System.Boolean,FixedMathSharp.Vector3d&,FixedMathSharp.Fixed64&)
TryGetNonNegativeAxisPlaneRatio(FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Fixed64,FixedMathSharp.Signed192&,FixedMathSharp.Signed320&)
ContainsAxisPlanePoint(FixedMathSharp.Geometry.FixedTriangle,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed192,FixedMathSharp.Signed320)
GetAxisPlaneHalfspaceSign(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed192,FixedMathSharp.Signed320)
ContainsStationaryPoint(FixedMathSharp.Geometry.FixedTriangle,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Fixed64)
GetStationaryHalfspaceSign(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Signed192,FixedMathSharp.Signed320,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Fixed64)
GetEdgeProducts(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Signed320&,FixedMathSharp.Signed320&)
GetWitnessCoordinate(FixedMathSharp.Fixed64,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Signed320,FixedMathSharp.Signed576,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)
GetAxisPlaneCoordinate(FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Signed192,FixedMathSharp.Signed320)
GetRadialNormalComponent(FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Fixed64)
GetStationaryDirectionComponent(FixedMathSharp.Signed576,FixedMathSharp.Fixed64,FixedMathSharp.Signed320,FixedMathSharp.Signed320)
GetDot(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d)
GetDot(FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d)
GetDot(FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192)
GetCross(FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192,FixedMathSharp.Signed192&,FixedMathSharp.Signed192&,FixedMathSharp.Signed192&)