< Summary

Information
Class: FixedMathSharp.Geometry.FixedSlabProjection
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Primitives/FixedSlabProjection.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 100
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryGetCapsuleSupport(...)100%11100%
TryGetCylinderSupport(...)100%11100%
TryGetConeSupport(...)100%11100%
Validate(...)100%1212100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Primitives/FixedSlabProjection.cs

#LineLine coverage
 1//=======================================================================
 2// FixedSlabProjection.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/// Provides planar support points for centered finite shapes clipped to a
 14/// closed world-Y slab.
 15/// </summary>
 16public static class FixedSlabProjection
 17{
 18    /// <summary>
 19    /// Attempts to return the support point of a centered capsule's X/Z
 20    /// projection after clipping the capsule to <paramref name="slabY"/>.
 21    /// </summary>
 22    public static bool TryGetCapsuleSupport(
 23        Vector3d center,
 24        Vector3d axisDirection,
 25        Fixed64 axisLength,
 26        Fixed64 radius,
 27        FixedRange slabY,
 28        Vector2d direction,
 29        out Vector2d support)
 30    {
 14731        Validate(axisDirection, axisLength, nameof(axisLength), radius, slabY, direction, requirePositiveLength: false);
 14432        return WideSlabProjection.TryGetCapsuleSupport(
 14433            center, axisDirection, axisLength, radius, slabY, direction, out support);
 34    }
 35
 36    /// <summary>
 37    /// Attempts to return the support point of a centered finite cylinder's
 38    /// X/Z projection after clipping the cylinder to <paramref name="slabY"/>.
 39    /// </summary>
 40    public static bool TryGetCylinderSupport(
 41        Vector3d center,
 42        Vector3d axisDirection,
 43        Fixed64 axisLength,
 44        Fixed64 radius,
 45        FixedRange slabY,
 46        Vector2d direction,
 47        out Vector2d support)
 48    {
 1649        Validate(axisDirection, axisLength, nameof(axisLength), radius, slabY, direction, requirePositiveLength: true);
 1550        return WideSlabProjection.TryGetCylinderSupport(
 1551            center, axisDirection, axisLength, radius, slabY, direction, out support);
 52    }
 53
 54    /// <summary>
 55    /// Attempts to return the support point of a centered finite cone's X/Z
 56    /// projection after clipping the cone to <paramref name="slabY"/>.
 57    /// </summary>
 58    /// <param name="center">The cone center.</param>
 59    /// <param name="axisDirection">The normalized direction from base to apex.</param>
 60    /// <param name="height">The positive full parametric height.</param>
 61    /// <param name="radius">The nonnegative base radius.</param>
 62    /// <param name="slabY">The inclusive world-Y clipping interval.</param>
 63    /// <param name="direction">The normalized X/Z support direction.</param>
 64    /// <param name="support">The winning planar support point when representable.</param>
 65    /// <returns><see langword="true"/> when the clipped cone has a representable support point.</returns>
 66    public static bool TryGetConeSupport(
 67        Vector3d center,
 68        Vector3d axisDirection,
 69        Fixed64 height,
 70        Fixed64 radius,
 71        FixedRange slabY,
 72        Vector2d direction,
 73        out Vector2d support)
 74    {
 2575        Validate(axisDirection, height, nameof(height), radius, slabY, direction, requirePositiveLength: true);
 2276        return WideSlabProjection.TryGetConeSupport(
 2277            center, axisDirection, height, radius, slabY, direction, out support);
 78    }
 79
 80    private static void Validate(
 81        Vector3d axisDirection,
 82        Fixed64 length,
 83        string lengthParameterName,
 84        Fixed64 radius,
 85        FixedRange slabY,
 86        Vector2d direction,
 87        bool requirePositiveLength)
 88    {
 18889        if (!axisDirection.IsNormalized())
 190            throw new ArgumentException("Shape axis direction must be normalized.", nameof(axisDirection));
 18791        if (requirePositiveLength ? length <= Fixed64.Zero : length < Fixed64.Zero)
 392            throw new ArgumentOutOfRangeException(lengthParameterName);
 18493        if (radius < Fixed64.Zero)
 194            throw new ArgumentOutOfRangeException(nameof(radius));
 18395        if (slabY.Min > slabY.Max)
 196            throw new ArgumentException("Slab minimum must not exceed its maximum.", nameof(slabY));
 18297        if (!direction.IsNormalized())
 198            throw new ArgumentException("Planar support direction must be normalized.", nameof(direction));
 18199    }
 100}