< Summary

Information
Class: FixedMathSharp.Fixed3x3Extensions
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Matrices/Fixed3x3.Extensions.cs
Line coverage
100%
Covered lines: 32
Uncovered lines: 0
Coverable lines: 32
Total lines: 79
Line coverage: 100%
Branch coverage
100%
Covered branches: 34
Total branches: 34
Branch coverage: 100%
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(...)100%1616100%
FuzzyEqual(...)100%1818100%

File(s)

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

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3namespace FixedMathSharp;
 4
 5/// <summary>
 6/// Provides extension methods for the Fixed3x3 structure, enabling additional transformation and comparison operations.
 7/// </summary>
 8public static class Fixed3x3Extensions
 9{
 10    #region Transformations
 11
 12    /// <inheritdoc cref="Fixed3x3.ExtractScale(Fixed3x3)" />
 13    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 14    public static Vector3d ExtractScale(this Fixed3x3 matrix)
 115    {
 116        return Fixed3x3.ExtractScale(matrix);
 117    }
 18
 19    /// <inheritdoc cref="Fixed3x3.SetScale(Fixed3x3, Vector3d)" />
 20    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 21    public static Fixed3x3 SetScale(this ref Fixed3x3 matrix, Vector3d localScale)
 422    {
 423        return matrix = Fixed3x3.SetScale(matrix, localScale);
 424    }
 25
 26    /// <inheritdoc cref="Fixed3x3.SetGlobalScale(Fixed3x3, Vector3d)" />
 27    public static Fixed3x3 SetGlobalScale(this ref Fixed3x3 matrix, Vector3d globalScale)
 228    {
 229        return matrix = Fixed3x3.SetGlobalScale(matrix, globalScale);
 230    }
 31
 32    #endregion
 33
 34    #region Equality
 35
 36    /// <summary>
 37    /// Compares two Fixed3x3 for approximate equality, allowing a fixed absolute difference between components.
 38    /// </summary>
 39    /// <param name="f1">The current Fixed3x3.</param>
 40    /// <param name="f2">The Fixed3x3 to compare against.</param>
 41    /// <param name="allowedDifference">The allowed absolute difference between each component.</param>
 42    /// <returns>True if the components are within the allowed difference, false otherwise.</returns>
 43    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 44    public static bool FuzzyEqualAbsolute(this Fixed3x3 f1, Fixed3x3 f2, Fixed64 allowedDifference)
 1145    {
 1146        return (f1.m00 - f2.m00).Abs() <= allowedDifference &&
 1147               (f1.m01 - f2.m01).Abs() <= allowedDifference &&
 1148               (f1.m02 - f2.m02).Abs() <= allowedDifference &&
 1149               (f1.m10 - f2.m10).Abs() <= allowedDifference &&
 1150               (f1.m11 - f2.m11).Abs() <= allowedDifference &&
 1151               (f1.m12 - f2.m12).Abs() <= allowedDifference &&
 1152               (f1.m20 - f2.m20).Abs() <= allowedDifference &&
 1153               (f1.m21 - f2.m21).Abs() <= allowedDifference &&
 1154               (f1.m22 - f2.m22).Abs() <= allowedDifference;
 1155    }
 56
 57    /// <summary>
 58    /// Compares two Fixed3x3 for approximate equality, allowing a fractional percentage (defaults to ~1%) difference be
 59    /// </summary>
 60    /// <param name="f1">The current Fixed3x3.</param>
 61    /// <param name="f2">The Fixed3x3 to compare against.</param>
 62    /// <param name="percentage">The allowed fractional difference (percentage) for each component.</param>
 63    /// <returns>True if the components are within the allowed percentage difference, false otherwise.</returns>
 64    public static bool FuzzyEqual(this Fixed3x3 f1, Fixed3x3 f2, Fixed64? percentage = null)
 1265    {
 1266        Fixed64 p = percentage ?? Fixed64.Epsilon;
 1267        return f1.m00.FuzzyComponentEqual(f2.m00, p) &&
 1268               f1.m01.FuzzyComponentEqual(f2.m01, p) &&
 1269               f1.m02.FuzzyComponentEqual(f2.m02, p) &&
 1270               f1.m10.FuzzyComponentEqual(f2.m10, p) &&
 1271               f1.m11.FuzzyComponentEqual(f2.m11, p) &&
 1272               f1.m12.FuzzyComponentEqual(f2.m12, p) &&
 1273               f1.m20.FuzzyComponentEqual(f2.m20, p) &&
 1274               f1.m21.FuzzyComponentEqual(f2.m21, p) &&
 1275               f1.m22.FuzzyComponentEqual(f2.m22, p);
 1276    }
 77
 78    #endregion
 79}