< Summary

Information
Class: Gravitas.Colliders.PolygonMassProperties2D
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/MassProperties/PolygonMassProperties2D.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 35
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryGetWeightAndCentroid(...)100%22100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/MassProperties/PolygonMassProperties2D.cs

#LineLine coverage
 1//=======================================================================
 2// PolygonMassProperties2D.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
 10using FixedMathSharp;
 11using FixedMathSharp.Geometry;
 12
 13namespace Gravitas.Colliders;
 14
 15/// <summary>
 16/// Owns exact mass-property interpretation for convex polygon area.
 17/// </summary>
 18internal static class PolygonMassProperties2D
 19{
 20    internal static bool TryGetWeightAndCentroid(
 21        ReadOnlySpan<Vector2d> vertices,
 22        out ExactMassWeight weight,
 23        out Vector2d centroid)
 24    {
 555325        bool result =
 555326            WideConvex2dRelations.TryGetSignedDoubleAreaAndCentroid(
 555327                vertices,
 555328                out Signed320 signedDoubleArea,
 555329                out centroid);
 555330        weight = result
 555331            ? ExactMassProperties.CreateAreaWeight(signedDoubleArea)
 555332            : ExactMassWeight.Zero;
 555333        return result;
 34    }
 35}