Net.Like.Xue.Tokyo/Assets/BITKit/Core/Mathematics/Float2.cs

40 lines
1.1 KiB
C#

using System;
namespace BITKit
{
public static partial class MathB
{
public static bool Parallel(float x, float y)
{
return (x, y) switch
{
( > 0, > 0) => true,
( < 0, < 0) => true,
_ => false,
};
}
public static bool IsNormal(this float self, int range = int.MaxValue)
{
return
/* self > -range
&& self < range
&& float.IsNaN(self) is false
&& float.IsSubnormal(self) is false
&& self is not float.Epsilon
&& float.IsInfinity(self) is false
&& float.IsPositiveInfinity(self) is false
; */
self is not 0
&& MathF.Abs(self) > 0.001;
}
public static float Fix(this float self)
{
return Math.Abs(self) > 0.01 ? self : 0;
}
public static float Lerp(float firstFloat, float secondFloat, float by)
{
return firstFloat * (1 - by) + secondFloat * by;
}
}
}