You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
[Mono] Approximate equality
This commit is contained in:
@@ -143,6 +143,15 @@ namespace Godot
|
||||
return (weight - from) / (to - from);
|
||||
}
|
||||
|
||||
public static bool IsEqualApprox(real_t a, real_t b)
|
||||
{
|
||||
real_t tolerance = Epsilon * Abs(a);
|
||||
if (tolerance < Epsilon) {
|
||||
tolerance = Epsilon;
|
||||
}
|
||||
return Abs(a - b) < tolerance;
|
||||
}
|
||||
|
||||
public static bool IsInf(real_t s)
|
||||
{
|
||||
return real_t.IsInfinity(s);
|
||||
@@ -153,6 +162,11 @@ namespace Godot
|
||||
return real_t.IsNaN(s);
|
||||
}
|
||||
|
||||
public static bool IsZeroApprox(real_t s)
|
||||
{
|
||||
return Abs(s) < Epsilon;
|
||||
}
|
||||
|
||||
public static real_t Lerp(real_t from, real_t to, real_t weight)
|
||||
{
|
||||
return from + (to - from) * weight;
|
||||
|
||||
Reference in New Issue
Block a user