< 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: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 100
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%
ExtractLossyScale(...)100%11100%
SetScale(...)100%11100%
SetGlobalScale(...)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/Fixed3x3.Extensions.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.ExtractScale(Fixed3x3)" />
 20    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 121    public static Vector3d ExtractScale(this Fixed3x3 matrix) => Fixed3x3.ExtractScale(matrix);
 22
 23    /// <inheritdoc cref="Fixed3x3.ExtractLossyScale(Fixed3x3)" />
 24    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 125    public static Vector3d ExtractLossyScale(this Fixed3x3 matrix) => Fixed3x3.ExtractLossyScale(matrix);
 26
 27    /// <inheritdoc cref="Fixed3x3.SetScale(Fixed3x3, Vector3d)" />
 28    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 29    public static Fixed3x3 SetScale(this ref Fixed3x3 matrix, Vector3d localScale) =>
 430        matrix = Fixed3x3.SetScale(matrix, localScale);
 31
 32    /// <inheritdoc cref="Fixed3x3.SetGlobalScale(Fixed3x3, Vector3d)" />
 33    public static Fixed3x3 SetGlobalScale(this ref Fixed3x3 matrix, Vector3d globalScale) =>
 234        matrix = Fixed3x3.SetGlobalScale(matrix, globalScale);
 35
 36    /// <inheritdoc cref="Fixed3x3.Lerp(Fixed3x3, Fixed3x3, Fixed64)" />
 37    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 38    public static Fixed3x3 Lerp(this Fixed3x3 matrix, Fixed3x3 target, Fixed64 amount) =>
 139        Fixed3x3.Lerp(matrix, target, amount);
 40
 41    /// <inheritdoc cref="Fixed3x3.Transpose(Fixed3x3)" />
 42    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 143    public static Fixed3x3 Transpose(this Fixed3x3 matrix) => Fixed3x3.Transpose(matrix);
 44
 45    /// <inheritdoc cref="Fixed3x3.TransformDirection(Fixed3x3, Vector3d)" />
 46    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 47    public static Vector3d TransformDirection(this Fixed3x3 matrix, Vector3d direction) =>
 148        Fixed3x3.TransformDirection(matrix, direction);
 49
 50    /// <inheritdoc cref="Fixed3x3.InverseTransformDirection(Fixed3x3, Vector3d)" />
 51    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 52    public static Vector3d InverseTransformDirection(this Fixed3x3 matrix, Vector3d direction) =>
 153        Fixed3x3.InverseTransformDirection(matrix, direction);
 54
 55    #endregion
 56
 57    #region Equality
 58
 59    /// <summary>
 60    /// Compares two Fixed3x3 for approximate equality, allowing a fixed absolute difference between components.
 61    /// </summary>
 62    /// <param name="f1">The current Fixed3x3.</param>
 63    /// <param name="f2">The Fixed3x3 to compare against.</param>
 64    /// <param name="allowedDifference">The allowed absolute difference between each component.</param>
 65    /// <returns>True if the components are within the allowed difference, false otherwise.</returns>
 66    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 67    public static bool FuzzyEqualAbsolute(this Fixed3x3 f1, Fixed3x3 f2, Fixed64 allowedDifference) =>
 1168         (f1.M11 - f2.M11).Abs() <= allowedDifference &&
 1169        (f1.M12 - f2.M12).Abs() <= allowedDifference &&
 1170        (f1.M13 - f2.M13).Abs() <= allowedDifference &&
 1171        (f1.M21 - f2.M21).Abs() <= allowedDifference &&
 1172        (f1.M22 - f2.M22).Abs() <= allowedDifference &&
 1173        (f1.M23 - f2.M23).Abs() <= allowedDifference &&
 1174        (f1.M31 - f2.M31).Abs() <= allowedDifference &&
 1175        (f1.M32 - f2.M32).Abs() <= allowedDifference &&
 1176        (f1.M33 - f2.M33).Abs() <= allowedDifference;
 77
 78    /// <summary>
 79    /// Compares two Fixed3x3 for approximate equality, allowing a fractional percentage (defaults to ~1%) difference be
 80    /// </summary>
 81    /// <param name="f1">The current Fixed3x3.</param>
 82    /// <param name="f2">The Fixed3x3 to compare against.</param>
 83    /// <param name="percentage">The allowed fractional difference (percentage) for each component.</param>
 84    /// <returns>True if the components are within the allowed percentage difference, false otherwise.</returns>
 85    public static bool FuzzyEqual(this Fixed3x3 f1, Fixed3x3 f2, Fixed64? percentage = null)
 86    {
 1287        Fixed64 p = percentage ?? Fixed64.Epsilon;
 1288        return f1.M11.FuzzyComponentEqual(f2.M11, p) &&
 1289               f1.M12.FuzzyComponentEqual(f2.M12, p) &&
 1290               f1.M13.FuzzyComponentEqual(f2.M13, p) &&
 1291               f1.M21.FuzzyComponentEqual(f2.M21, p) &&
 1292               f1.M22.FuzzyComponentEqual(f2.M22, p) &&
 1293               f1.M23.FuzzyComponentEqual(f2.M23, p) &&
 1294               f1.M31.FuzzyComponentEqual(f2.M31, p) &&
 1295               f1.M32.FuzzyComponentEqual(f2.M32, p) &&
 1296               f1.M33.FuzzyComponentEqual(f2.M33, p);
 97    }
 98
 99    #endregion
 100}