< Summary

Information
Class: FixedMathSharp.Fixed3x3Extensions
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Extensions/Fixed3x3.Extensions.cs
Line coverage
100%
Covered lines: 32
Uncovered lines: 0
Coverable lines: 32
Total lines: 77
Line coverage: 100%
Branch coverage
52%
Covered branches: 18
Total branches: 34
Branch coverage: 52.9%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ExtractScale(...)100%11100%
SetScale(...)100%11100%
SetGlobalScale(...)100%11100%
FuzzyEqualAbsolute(...)50%1616100%
FuzzyEqual(...)55.55%1818100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Extensions/Fixed3x3.Extensions.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3namespace FixedMathSharp
 4{
 5    public static class Fixed3x3Extensions
 6    {
 7        #region Transformations
 8
 9        /// <inheritdoc cref="Fixed3x3.ExtractScale(Fixed3x3)" />
 10        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 11        public static Vector3d ExtractScale(this Fixed3x3 matrix)
 112        {
 113            return Fixed3x3.ExtractScale(matrix);
 114        }
 15
 16        /// <inheritdoc cref="Fixed3x3.SetScale(Fixed3x3, Vector3d)" />
 17        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 18        public static Fixed3x3 SetScale(this ref Fixed3x3 matrix, Vector3d localScale)
 419        {
 420            return matrix = Fixed3x3.SetScale(matrix, localScale);
 421        }
 22
 23        /// <inheritdoc cref="Fixed3x3.SetGlobalScale(Fixed3x3, Vector3d)" />
 24        public static Fixed3x3 SetGlobalScale(this ref Fixed3x3 matrix, Vector3d globalScale)
 225        {
 226            return matrix = Fixed3x3.SetGlobalScale(matrix, globalScale);
 227        }
 28
 29        #endregion
 30
 31        #region Equality
 32
 33        /// <summary>
 34        /// Compares two Fixed3x3 for approximate equality, allowing a fixed absolute difference between components.
 35        /// </summary>
 36        /// <param name="f1">The current Fixed3x3.</param>
 37        /// <param name="f2">The Fixed3x3 to compare against.</param>
 38        /// <param name="allowedDifference">The allowed absolute difference between each component.</param>
 39        /// <returns>True if the components are within the allowed difference, false otherwise.</returns>
 40        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 41        public static bool FuzzyEqualAbsolute(this Fixed3x3 f1, Fixed3x3 f2, Fixed64 allowedDifference)
 242        {
 243            return (f1.m00 - f2.m00).Abs() <= allowedDifference &&
 244                   (f1.m01 - f2.m01).Abs() <= allowedDifference &&
 245                   (f1.m02 - f2.m02).Abs() <= allowedDifference &&
 246                   (f1.m10 - f2.m10).Abs() <= allowedDifference &&
 247                   (f1.m11 - f2.m11).Abs() <= allowedDifference &&
 248                   (f1.m12 - f2.m12).Abs() <= allowedDifference &&
 249                   (f1.m20 - f2.m20).Abs() <= allowedDifference &&
 250                   (f1.m21 - f2.m21).Abs() <= allowedDifference &&
 251                   (f1.m22 - f2.m22).Abs() <= allowedDifference;
 252        }
 53
 54        /// <summary>
 55        /// Compares two Fixed3x3 for approximate equality, allowing a fractional percentage (defaults to ~1%) differenc
 56        /// </summary>
 57        /// <param name="f1">The current Fixed3x3.</param>
 58        /// <param name="f2">The Fixed3x3 to compare against.</param>
 59        /// <param name="percentage">The allowed fractional difference (percentage) for each component.</param>
 60        /// <returns>True if the components are within the allowed percentage difference, false otherwise.</returns>
 61        public static bool FuzzyEqual(this Fixed3x3 f1, Fixed3x3 f2, Fixed64? percentage = null)
 362        {
 363            Fixed64 p = percentage ?? Fixed64.Epsilon;
 364            return f1.m00.FuzzyComponentEqual(f2.m00, p) &&
 365                   f1.m01.FuzzyComponentEqual(f2.m01, p) &&
 366                   f1.m02.FuzzyComponentEqual(f2.m02, p) &&
 367                   f1.m10.FuzzyComponentEqual(f2.m10, p) &&
 368                   f1.m11.FuzzyComponentEqual(f2.m11, p) &&
 369                   f1.m12.FuzzyComponentEqual(f2.m12, p) &&
 370                   f1.m20.FuzzyComponentEqual(f2.m20, p) &&
 371                   f1.m21.FuzzyComponentEqual(f2.m21, p) &&
 372                   f1.m22.FuzzyComponentEqual(f2.m22, p);
 373        }
 74
 75        #endregion
 76    }
 77}