You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add inverse hyperbolic functions asinh(), acosh() & atanh()
GDScript has the following built-in trigonometry functions: - `sin()` - `cos()` - `tan()` - `asin()` - `acos()` - `atan()` - `atan()` - `sinh()` - `cosh()` - `tanh()` However, it lacks the hyperbolic arc (also known as inverse hyperbolic) functions: - `asinh()` - `acosh()` - `atanh()` Implement them by just exposing the C++ Math library, but clamping its values to the closest real defined value. For the cosine, clamp input values lower than 1 to 1. In the case of the tangent, where the limit value is infinite, clamp it to -inf or +inf. References #78377 Fixes godotengine/godot-proposals#7110
This commit is contained in:
@@ -81,6 +81,18 @@ double VariantUtilityFunctions::atan2(double y, double x) {
|
||||
return Math::atan2(y, x);
|
||||
}
|
||||
|
||||
double VariantUtilityFunctions::asinh(double arg) {
|
||||
return Math::asinh(arg);
|
||||
}
|
||||
|
||||
double VariantUtilityFunctions::acosh(double arg) {
|
||||
return Math::acosh(arg);
|
||||
}
|
||||
|
||||
double VariantUtilityFunctions::atanh(double arg) {
|
||||
return Math::atanh(arg);
|
||||
}
|
||||
|
||||
double VariantUtilityFunctions::sqrt(double x) {
|
||||
return Math::sqrt(x);
|
||||
}
|
||||
@@ -1502,6 +1514,10 @@ void Variant::_register_variant_utility_functions() {
|
||||
|
||||
FUNCBINDR(atan2, sarray("y", "x"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
|
||||
FUNCBINDR(asinh, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(acosh, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(atanh, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
|
||||
FUNCBINDR(sqrt, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(fmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(fposmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
|
||||
Reference in New Issue
Block a user