safe aSin
This commit is contained in:
parent
40457bbdc0
commit
bf0a10d62f
1
minetest-api.d.ts
vendored
1
minetest-api.d.ts
vendored
@ -1750,6 +1750,7 @@ declare global {
|
||||
function truncate(floating: number): number;
|
||||
function fma(x: number, y: number, z: number): number;
|
||||
function invsqrt(r: number): number;
|
||||
function safeAsin(r: number): number;
|
||||
}
|
||||
|
||||
namespace string {
|
||||
|
@ -6,6 +6,7 @@ namespace utility {
|
||||
const PI2 = math.pi * 2;
|
||||
const random = math.random;
|
||||
const sqrt = math.sqrt;
|
||||
const asin = math.asin;
|
||||
|
||||
export function randomRange(min: number, max: number): number {
|
||||
return (random() * (max - min) + min);
|
||||
@ -64,4 +65,8 @@ namespace utility {
|
||||
return 1.0 / sqrt(r);
|
||||
};
|
||||
|
||||
math.safeAsin = function (r: number): number {
|
||||
return r <= -1.0 ? -PI_HALF : r >= 1.0 ? PI_HALF : asin(r);
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user