< Summary

Information
Class: FixedMathSharp.Fixed3x3Extensions
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Matrices/Fixed3x3Extensions.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 91
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
ExtractScaleMagnitudes(...)100%11100%
ExtractLossyScale(...)100%11100%
Lerp(...)100%11100%
Transpose(...)100%11100%
TransformDirection(...)100%11100%
InverseTransformDirection(...)100%11100%
FuzzyEqualAbsolute(...)100%1616100%
FuzzyEqual(...)100%1818100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Matrices/Fixed3x3Extensions.cs

#LineLine coverage
 1//=======================================================================
 2// Fixed3x3.Extensions.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.Runtime.CompilerServices;
 9
 10namespace FixedMathSharp;
 11
 12/// <summary>
 13/// Provides extension methods for the Fixed3x3 structure, enabling additional transformation and comparison operations.
 14/// </summary>
 15public static class Fixed3x3Extensions
 16{
 17    #region Transformations
 18
 19    /// <inheritdoc cref="Fixed3x3.ExtractScaleMagnitudes(Fixed3x3)" />
 20    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 421    public static Vector3d ExtractScaleMagnitudes(this Fixed3x3 matrix) => Fixed3x3.ExtractScaleMagnitudes(matrix);
 22
 23    /// <inheritdoc cref="Fixed3x3.ExtractLossyScale(Fixed3x3)" />
 24    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 425    public static Vector3d ExtractLossyScale(this Fixed3x3 matrix) => Fixed3x3.ExtractLossyScale(matrix);
 26
 27    /// <inheritdoc cref="Fixed3x3.Lerp(Fixed3x3, Fixed3x3, Fixed64)" />
 28    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 29    public static Fixed3x3 Lerp(this Fixed3x3 matrix, Fixed3x3 target, Fixed64 amount) =>
 130        Fixed3x3.Lerp(matrix, target, amount);
 31
 32    /// <inheritdoc cref="Fixed3x3.Transpose(Fixed3x3)" />
 33    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 134    public static Fixed3x3 Transpose(this Fixed3x3 matrix) => Fixed3x3.Transpose(matrix);
 35
 36    /// <inheritdoc cref="Fixed3x3.TransformDirection(Fixed3x3, Vector3d)" />
 37    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 38    public static Vector3d TransformDirection(this Fixed3x3 matrix, Vector3d direction) =>
 139        Fixed3x3.TransformDirection(matrix, direction);
 40
 41    /// <inheritdoc cref="Fixed3x3.InverseTransformDirection(Fixed3x3, Vector3d)" />
 42    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 43    public static Vector3d InverseTransformDirection(this Fixed3x3 matrix, Vector3d direction) =>
 144        Fixed3x3.InverseTransformDirection(matrix, direction);
 45
 46    #endregion
 47
 48    #region Equality
 49
 50    /// <summary>
 51    /// Compares two Fixed3x3 for approximate equality, allowing a fixed absolute difference between components.
 52    /// </summary>
 53    /// <param name="f1">The current Fixed3x3.</param>
 54    /// <param name="f2">The Fixed3x3 to compare against.</param>
 55    /// <param name="allowedDifference">The allowed absolute difference between each component.</param>
 56    /// <returns>True if the components are within the allowed difference, false otherwise.</returns>
 57    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 58    public static bool FuzzyEqualAbsolute(this Fixed3x3 f1, Fixed3x3 f2, Fixed64 allowedDifference) =>
 4359         (f1.M11 - f2.M11).Abs() <= allowedDifference &&
 4360        (f1.M12 - f2.M12).Abs() <= allowedDifference &&
 4361        (f1.M13 - f2.M13).Abs() <= allowedDifference &&
 4362        (f1.M21 - f2.M21).Abs() <= allowedDifference &&
 4363        (f1.M22 - f2.M22).Abs() <= allowedDifference &&
 4364        (f1.M23 - f2.M23).Abs() <= allowedDifference &&
 4365        (f1.M31 - f2.M31).Abs() <= allowedDifference &&
 4366        (f1.M32 - f2.M32).Abs() <= allowedDifference &&
 4367        (f1.M33 - f2.M33).Abs() <= allowedDifference;
 68
 69    /// <summary>
 70    /// Compares two Fixed3x3 for approximate equality, allowing a fractional percentage (defaults to ~1%) difference be
 71    /// </summary>
 72    /// <param name="f1">The current Fixed3x3.</param>
 73    /// <param name="f2">The Fixed3x3 to compare against.</param>
 74    /// <param name="percentage">The allowed fractional difference (percentage) for each component.</param>
 75    /// <returns>True if the components are within the allowed percentage difference, false otherwise.</returns>
 76    public static bool FuzzyEqual(this Fixed3x3 f1, Fixed3x3 f2, Fixed64? percentage = null)
 77    {
 1278        Fixed64 p = percentage ?? Fixed64.Epsilon;
 1279        return f1.M11.FuzzyComponentEqual(f2.M11, p) &&
 1280               f1.M12.FuzzyComponentEqual(f2.M12, p) &&
 1281               f1.M13.FuzzyComponentEqual(f2.M13, p) &&
 1282               f1.M21.FuzzyComponentEqual(f2.M21, p) &&
 1283               f1.M22.FuzzyComponentEqual(f2.M22, p) &&
 1284               f1.M23.FuzzyComponentEqual(f2.M23, p) &&
 1285               f1.M31.FuzzyComponentEqual(f2.M31, p) &&
 1286               f1.M32.FuzzyComponentEqual(f2.M32, p) &&
 1287               f1.M33.FuzzyComponentEqual(f2.M33, p);
 88    }
 89
 90    #endregion
 91}