BITKit/Packages/Core/Mathematics/Float2.cs

39 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
}
}
}