< Summary

Information
Class: FixedMathSharp.Vector4dExtensions
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Vectors/Vector4d.Extensions.cs
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 73
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ClampOneInPlace(...)100%11100%
Abs(...)100%11100%
Sign(...)100%11100%
FuzzyEqualAbsolute(...)100%66100%
FuzzyEqual(...)100%88100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Vectors/Vector4d.Extensions.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3namespace FixedMathSharp;
 4
 5/// <summary>
 6/// Provides extension methods for the Vector4d type to support additional vector operations and comparisons.
 7/// </summary>
 8public static partial class Vector4dExtensions
 9{
 10    #region Vector4d Operations
 11
 12    /// <summary>
 13    /// Clamps each component of the vector to the range [-1, 1] and returns the clamped vector.
 14    /// </summary>
 15    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 16    public static Vector4d ClampOneInPlace(this Vector4d v)
 117    {
 118        v.x = v.x.ClampOne();
 119        v.y = v.y.ClampOne();
 120        v.z = v.z.ClampOne();
 121        v.w = v.w.ClampOne();
 122        return v;
 123    }
 24
 25    #endregion
 26
 27    #region Conversion
 28
 29    /// <inheritdoc cref="Vector4d.Abs(Vector4d)" />
 30    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 31    public static Vector4d Abs(this Vector4d value)
 132    {
 133        return Vector4d.Abs(value);
 134    }
 35
 36    /// <inheritdoc cref="Vector4d.Sign(Vector4d)" />
 37    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 38    public static Vector4d Sign(this Vector4d value)
 139    {
 140        return Vector4d.Sign(value);
 141    }
 42
 43    #endregion
 44
 45    #region Equality
 46
 47    /// <summary>
 48    /// Compares two vectors for approximate equality, allowing a fixed absolute difference.
 49    /// </summary>
 50    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 51    public static bool FuzzyEqualAbsolute(this Vector4d me, Vector4d other, Fixed64 allowedDifference)
 552    {
 553        return (me.x - other.x).Abs() <= allowedDifference &&
 554               (me.y - other.y).Abs() <= allowedDifference &&
 555               (me.z - other.z).Abs() <= allowedDifference &&
 556               (me.w - other.w).Abs() <= allowedDifference;
 557    }
 58
 59    /// <summary>
 60    /// Compares two vectors for approximate equality, allowing a fractional difference.
 61    /// </summary>
 62    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 63    public static bool FuzzyEqual(this Vector4d me, Vector4d other, Fixed64? percentage = null)
 764    {
 765        Fixed64 p = percentage ?? Fixed64.Epsilon;
 766        return me.x.FuzzyComponentEqual(other.x, p) &&
 767               me.y.FuzzyComponentEqual(other.y, p) &&
 768               me.z.FuzzyComponentEqual(other.z, p) &&
 769               me.w.FuzzyComponentEqual(other.w, p);
 770    }
 71
 72    #endregion
 73}