feat: Engine.Core.MathExtensions

This commit is contained in:
Syntriax 2024-10-20 15:12:20 +03:00
parent fc34a60f30
commit fdc38fc800
1 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,70 @@
using System;
using System.Numerics;
namespace Syntriax.Engine.Core;
public static class MathExtensions
{
/// <inheritdoc cref="Math.Abs{T}(T)" />
public static T Abs<T>(this T x) where T : INumber<T> => Math.Abs(x);
/// <inheritdoc cref="Math.Acos(float)" />
public static float Acos(this float x) => Math.Acos(x);
/// <inheritdoc cref="Math.Asin(float)" />
public static float Asin(this float x) => Math.Asin(x);
/// <inheritdoc cref="Math.Atan2(float, float)" />
public static float Atan2(this float y, float x) => Math.Atan2(y, x);
/// <inheritdoc cref="Math.Atanh(float)" />
public static float Atanh(this float x) => Math.Atanh(x);
/// <inheritdoc cref="Math.Clamp{T}(T, T, T)" />
public static T Clamp<T>(this T x, T min, T max) where T : INumber<T> => Math.Clamp(x, min, max);
/// <inheritdoc cref="Math.Ceiling(float)" />
public static float Ceiling(this float x) => Math.Ceiling(x);
/// <inheritdoc cref="Math.CopySign(float, float)" />
public static float CopySign(this float x, float y) => Math.CopySign(x, y);
/// <inheritdoc cref="Math.Floor(float)" />
public static float Floor(this float x) => Math.Floor(x);
/// <inheritdoc cref="Math.IEEERemainder(float, float)" />
public static float IEEERemainder(this float x, float y) => Math.IEEERemainder(x, y);
/// <inheritdoc cref="Math.Log(float, float)" />
public static float Log(this float x, float y) => Math.Log(x, y);
/// <inheritdoc cref="Math.Max{T}(T, T)" />
public static T Max<T>(this T x, T y) where T : INumber<T> => Math.Max(x, y);
/// <inheritdoc cref="Math.AbsMax{T}(T, T)" />
public static T AbsMax<T>(this T x, T y) where T : INumber<T> => Math.AbsMax(x, y);
/// <inheritdoc cref="Math.Min{T}(T, T)" />
public static T Min<T>(this T x, T y) where T : INumber<T> => Math.Min(x, y);
/// <inheritdoc cref="Math.AbsMin{T}(T, T)" />
public static T AbsMin<T>(this T x, T y) where T : INumber<T> => Math.AbsMin(x, y);
/// <inheritdoc cref="Math.Pow(float, float)" />
public static float Pow(this float x, float y) => Math.Pow(x, y);
/// <inheritdoc cref="Math.Lerp{T}(T, T, T)" />
public static T Lerp<T>(this T x, T y, T t) where T : IFloatingPoint<T> => Math.Lerp(x, y, t);
/// <inheritdoc cref="Math.Round(float, int, MidpointRounding)" />
public static float Round(this float x, int digits, MidpointRounding mode) => Math.Round(x, digits, mode);
/// <inheritdoc cref="Math.Sqr{T}(T)" />
public static T Sqr<T>(this T x) where T : INumber<T> => Math.Sqr(x);
/// <inheritdoc cref="Math.Sqrt(float)" />
public static float Sqrt(this float x) => Math.Sqrt(x);
/// <inheritdoc cref="Math.Truncate(float)" />
public static float Truncate(this float x) => Math.Truncate(x);
}