< 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: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 92
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
Clamp(...)100%11100%
ClampOne(...)100%11100%
Lerp(...)100%11100%
UnclampedLerp(...)100%11100%
Midpoint(...)100%11100%
Max(...)100%11100%
Min(...)100%11100%
Transform(...)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
 1//=======================================================================
 2// Vector4d.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 Vector4d type to support additional vector operations and comparisons.
 14/// </summary>
 15public static partial class Vector4dExtensions
 16{
 17    #region Vector4d Operations
 18
 19    /// <inheritdoc cref="Vector4d.Clamp(Vector4d, Vector4d, Vector4d)" />
 20    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 121    public static Vector4d Clamp(this Vector4d value, Vector4d min, Vector4d max) => Vector4d.Clamp(value, min, max);
 22
 23    /// <inheritdoc cref="Vector4d.Clamp(Vector4d, Vector4d, Vector4d)" />
 24    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 125    public static Vector4d ClampOne(this Vector4d value) => Vector4d.Clamp(value, Vector4d.Negative, Vector4d.One);
 26
 27    /// <inheritdoc cref="Vector4d.Lerp(Vector4d, Vector4d, Fixed64)" />
 28    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 129    public static Vector4d Lerp(this Vector4d start, Vector4d end, Fixed64 amount) => Vector4d.Lerp(start, end, amount);
 30
 31    /// <inheritdoc cref="Vector4d.UnclampedLerp(Vector4d, Vector4d, Fixed64)" />
 32    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 33    public static Vector4d UnclampedLerp(this Vector4d start, Vector4d end, Fixed64 amount) =>
 134        Vector4d.UnclampedLerp(start, end, amount);
 35
 36    /// <inheritdoc cref="Vector4d.Midpoint(Vector4d, Vector4d)" />
 37    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 138    public static Vector4d Midpoint(this Vector4d value, Vector4d other) => Vector4d.Midpoint(value, other);
 39
 40    /// <inheritdoc cref="Vector4d.Max(Vector4d, Vector4d)" />
 41    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 142    public static Vector4d Max(this Vector4d value, Vector4d other) => Vector4d.Max(value, other);
 43
 44    /// <inheritdoc cref="Vector4d.Min(Vector4d, Vector4d)" />
 45    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 146    public static Vector4d Min(this Vector4d value, Vector4d other) => Vector4d.Min(value, other);
 47
 48    /// <inheritdoc cref="Vector4d.Transform(Fixed4x4, Vector4d)" />
 49    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 150    public static Vector4d Transform(this Vector4d vector, Fixed4x4 matrix) => Vector4d.Transform(matrix, vector);
 51
 52    #endregion
 53
 54    #region Conversion
 55
 56    /// <inheritdoc cref="Vector4d.Abs(Vector4d)" />
 57    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 158    public static Vector4d Abs(this Vector4d value) => Vector4d.Abs(value);
 59
 60    /// <inheritdoc cref="Vector4d.Sign(Vector4d)" />
 61    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 162    public static Vector4d Sign(this Vector4d value) => Vector4d.Sign(value);
 63
 64    #endregion
 65
 66    #region Equality
 67
 68    /// <summary>
 69    /// Compares two vectors for approximate equality, allowing a fixed absolute difference.
 70    /// </summary>
 71    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 72    public static bool FuzzyEqualAbsolute(this Vector4d me, Vector4d other, Fixed64 allowedDifference) =>
 573        (me.X - other.X).Abs() <= allowedDifference &&
 574        (me.Y - other.Y).Abs() <= allowedDifference &&
 575        (me.Z - other.Z).Abs() <= allowedDifference &&
 576        (me.W - other.W).Abs() <= allowedDifference;
 77
 78    /// <summary>
 79    /// Compares two vectors for approximate equality, allowing a fractional difference.
 80    /// </summary>
 81    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 82    public static bool FuzzyEqual(this Vector4d me, Vector4d other, Fixed64? percentage = null)
 83    {
 784        Fixed64 p = percentage ?? Fixed64.Epsilon;
 785        return me.X.FuzzyComponentEqual(other.X, p) &&
 786               me.Y.FuzzyComponentEqual(other.Y, p) &&
 787               me.Z.FuzzyComponentEqual(other.Z, p) &&
 788               me.W.FuzzyComponentEqual(other.W, p);
 89    }
 90
 91    #endregion
 92}