3 public const float PI = (float)Math.PI;
5 public const float E = (float)Math.E;
7 public static int Min(
int x1,
int x2) {
14 public static int Min(
int x1,
int x2,
int x3) =>
Min(
Min(x1, x2), x3);
16 public static int Min(
int x1,
int x2,
int x3,
int x4) =>
Min(
Min(
Min(x1, x2), x3), x4);
18 public static int Max(
int x1,
int x2) {
25 public static int Max(
int x1,
int x2,
int x3) =>
Max(
Max(x1, x2), x3);
27 public static int Max(
int x1,
int x2,
int x3,
int x4) =>
Max(
Max(
Max(x1, x2), x3), x4);
29 public static int Clamp(
int x,
int min,
int max) {
39 public static int Sign(
int x) => Math.Sign(x);
41 public static int Abs(
int x) => Math.Abs(x);
43 public static int Sqr(
int x) => x * x;
47 return (x & (x - 1)) == 0;
63 public static int Hash(
int key) => (int)
Hash((uint)key);
65 public static uint
Hash(uint key) {
74 public static long Min(
long x1,
long x2) {
81 public static long Min(
long x1,
long x2,
long x3) =>
Min(
Min(x1, x2), x3);
83 public static long Min(
long x1,
long x2,
long x3,
long x4) =>
Min(
Min(
Min(x1, x2), x3), x4);
85 public static long Max(
long x1,
long x2) {
92 public static long Max(
long x1,
long x2,
long x3) =>
Max(
Max(x1, x2), x3);
94 public static long Max(
long x1,
long x2,
long x3,
long x4) =>
Max(
Max(
Max(x1, x2), x3), x4);
96 public static long Clamp(
long x,
long min,
long max) {
106 public static long Sign(
long x) => Math.Sign(x);
108 public static long Abs(
long x) => Math.Abs(x);
110 public static long Sqr(
long x) => x * x;
114 return (x & (x - 1)) == 0;
131 public static float Min(
float x1,
float x2) {
138 public static float Min(
float x1,
float x2,
float x3) =>
Min(
Min(x1, x2), x3);
140 public static float Min(
float x1,
float x2,
float x3,
float x4) =>
Min(
Min(
Min(x1, x2), x3), x4);
142 public static float Max(
float x1,
float x2) {
149 public static float Max(
float x1,
float x2,
float x3) =>
Max(
Max(x1, x2), x3);
151 public static float Max(
float x1,
float x2,
float x3,
float x4) =>
Max(
Max(
Max(x1, x2), x3), x4);
153 public static float Clamp(
float x,
float min,
float max) {
173 public static float Sign(
float x) => Math.Sign(x);
175 public static float Abs(
float x) => Math.Abs(x);
177 public static float Floor(
float x) => (float)Math.Floor(x);
179 public static float Ceiling(
float x) => (float)Math.Ceiling(x);
181 public static float Round(
float x) => (float)Math.Round(x);
185 public static float Sqr(
float x) => x * x;
187 public static float Sqrt(
float x) => (float)Math.Sqrt(x);
189 public static float Sin(
float x) => (float)Math.Sin(x);
191 public static float Cos(
float x) => (float)Math.Cos(x);
193 public static float Tan(
float x) => (float)Math.Tan(x);
195 public static float Asin(
float x) => (float)Math.Asin(x);
197 public static float Acos(
float x) => (float)Math.Acos(x);
199 public static float Atan(
float x) => (float)Math.Atan(x);
201 public static float Atan2(
float y,
float x) => (float)Math.Atan2(y, x);
203 public static float Exp(
float n) => (float)Math.Exp(n);
205 public static float Log(
float x) => (float)Math.Log(x);
207 public static float Log10(
float x) => (float)Math.Log10(x);
209 public static float Pow(
float x,
float n) => (float)Math.Pow(x, n);
213 public static float Lerp(
float x1,
float x2,
float f) => x1 + (x2 - x1) * f;
215 public static float SmoothStep(
float min,
float max,
float x) {
216 x =
Clamp((x - min) / (max - min), 0f, 1f);
217 return x * x * (3f - 2f * x);
220 public static float CatmullRom(
float v1,
float v2,
float v3,
float v4,
float f) {
222 float num2 = num * f;
223 return 0.5f * (2f * v2 + (v3 - v1) * f + (2f * v1 - 5f * v2 + 4f * v3 - v4) * num + (3f * v2 - v1 - 3f * v3 + v4) * num2);
227 angle = (float)Math.IEEERemainder(angle, 6.2831854820251465);
228 if (angle > (
float)Math.PI) {
229 angle -= (float)Math.PI * 2f;
231 else if (angle <= -(
float)Math.PI) {
232 angle += (float)Math.PI * 2f;
237 public static float Sigmoid(
float x,
float steepness) {
244 float num =
Exp(steepness);
245 float num2 =
Exp(2f * steepness * x);
246 return num * (num2 - 1f) / ((num - 1f) * (num2 + num));
249 public static float DegToRad(
float degrees) => degrees / 180f * (float)Math.PI;
251 public static float RadToDeg(
float radians) => radians * 180f / (float)Math.PI;
253 public static double Min(
double x1,
double x2) {
260 public static double Min(
double x1,
double x2,
double x3) =>
Min(
Min(x1, x2), x3);
262 public static double Min(
double x1,
double x2,
double x3,
double x4) =>
Min(
Min(
Min(x1, x2), x3), x4);
264 public static double Max(
double x1,
double x2) {
271 public static double Max(
double x1,
double x2,
double x3) =>
Max(
Max(x1, x2), x3);
273 public static double Max(
double x1,
double x2,
double x3,
double x4) =>
Max(
Max(
Max(x1, x2), x3), x4);
275 public static double Clamp(
double x,
double min,
double max) {
295 public static double Sign(
double x) => Math.Sign(x);
297 public static double Abs(
double x) => Math.Abs(x);
299 public static double Floor(
double x) => Math.Floor(x);
301 public static double Ceiling(
double x) => Math.Ceiling(x);
303 public static double Round(
double x) => Math.Round(x);
307 public static double Sqr(
double x) => x * x;
309 public static double Sqrt(
double x) => Math.Sqrt(x);
311 public static double Sin(
double x) => Math.Sin(x);
313 public static double Cos(
double x) => Math.Cos(x);
315 public static double Tan(
double x) => Math.Tan(x);
317 public static double Asin(
double x) => Math.Asin(x);
319 public static double Acos(
double x) => Math.Acos(x);
321 public static double Atan(
double x) => Math.Atan(x);
323 public static double Atan2(
double y,
double x) => Math.Atan2(y, x);
325 public static double Exp(
double n) => Math.Exp(n);
327 public static double Log(
double x) => Math.Log(x);
329 public static double Log10(
double x) => Math.Log10(x);
331 public static double Pow(
double x,
double n) => Math.Pow(x, n);
335 public static double Lerp(
double x1,
double x2,
double f) => x1 + (x2 - x1) * f;
337 public static double SmoothStep(
double min,
double max,
double x) {
338 x =
Clamp((x - min) / (max - min), 0.0, 1.0);
339 return x * x * (3.0 - 2.0 * x);
342 public static double CatmullRom(
double v1,
double v2,
double v3,
double v4,
double f) {
344 double num2 = num * f;
345 return 0.5 * (2.0 * v2 + (v3 - v1) * f + (2.0 * v1 - 5.0 * v2 + 4.0 * v3 - v4) * num + (3.0 * v2 - v1 - 3.0 * v3 + v4) * num2);
349 angle = Math.IEEERemainder(angle, Math.PI * 2.0);
350 if (angle > 3.1415927410125732) {
351 angle -= Math.PI * 2.0;
353 else if (angle <= -Math.PI) {
354 angle += Math.PI * 2.0;
359 public static double DegToRad(
double degrees) => degrees / 180.0 * Math.PI;
361 public static double RadToDeg(
double radians) => radians * 180.0 / Math.PI;
363 public static float LinearStep(
float zero,
float one,
float f) =>
Saturate((f - zero) / (one - zero));
static float Max(float x1, float x2, float x3, float x4)
static double Sign(double x)
static double SmoothStep(double min, double max, double x)
static float RadToDeg(float radians)
static float Round(float x)
static int Min(int x1, int x2, int x3, int x4)
static double Abs(double x)
static float Acos(float x)
static int Clamp(int x, int min, int max)
static float Exp(float n)
static float Remainder(float x, float y)
static float Asin(float x)
static uint NextPowerOf2(uint x)
static long Min(long x1, long x2)
static float Sqrt(float x)
static float Pow(float x, float n)
static int Max(int x1, int x2, int x3)
static double Max(double x1, double x2)
static double RadToDeg(double radians)
static float Sqr(float x)
static double Sqr(double x)
static bool IsPowerOf2(uint x)
static float SmoothStep(float min, float max, float x)
static float Cos(float x)
static double PowSign(double x, double n)
static float Abs(float x)
static float Sin(float x)
static double Sqrt(double x)
static double Saturate(double x)
static double NormalizeAngle(double angle)
static float Max(float x1, float x2)
static double Exp(double n)
static double Min(double x1, double x2, double x3, double x4)
static double CatmullRom(double v1, double v2, double v3, double v4, double f)
static double Log10(double x)
static double Atan(double x)
static double Log(double x)
static int Min(int x1, int x2)
static float Min(float x1, float x2, float x3)
static float Log(float x)
static long Min(long x1, long x2, long x3, long x4)
static double DegToRad(double degrees)
static float Sign(float x)
static double Asin(double x)
static double Tan(double x)
static float Sigmoid(float x, float steepness)
static float Log10(float x)
static long Max(long x1, long x2, long x3)
static ulong NextPowerOf2(ulong x)
static long Max(long x1, long x2, long x3, long x4)
static double Max(double x1, double x2, double x3)
static float Atan(float x)
static int Max(int x1, int x2, int x3, int x4)
static float NormalizeAngle(float angle)
static double Max(double x1, double x2, double x3, double x4)
static long Min(long x1, long x2, long x3)
static double Cos(double x)
static float Tan(float x)
static double Sin(double x)
static double Floor(double x)
static double Lerp(double x1, double x2, double f)
static float Clamp(float x, float min, float max)
static double Pow(double x, double n)
static float Saturate(float x)
static float PowSign(float x, float n)
static double Acos(double x)
static double Remainder(double x, double y)
static double Clamp(double x, double min, double max)
static long Clamp(long x, long min, long max)
static double Round(double x)
static uint Hash(uint key)
static float Min(float x1, float x2, float x3, float x4)
static float Max(float x1, float x2, float x3)
static float Min(float x1, float x2)
static double Min(double x1, double x2, double x3)
static long Max(long x1, long x2)
static int Max(int x1, int x2)
static double Ceiling(double x)
static bool IsPowerOf2(long x)
static float Atan2(float y, float x)
static float Ceiling(float x)
static double Min(double x1, double x2)
static float CatmullRom(float v1, float v2, float v3, float v4, float f)
static double Atan2(double y, double x)
static int Min(int x1, int x2, int x3)
static float Floor(float x)
static float DegToRad(float degrees)
static float Lerp(float x1, float x2, float f)
static float LinearStep(float zero, float one, float f)