Appearance
Math
individual package can be found here
@riadh-adrani/math-utils.
inInterval()
checks if the given value is within the [min...max] interval.
ts
function inInterval(min: number, value: number, max: number): boolean;
min: minimum value.max: maximum value.value: tested value.
throws when
minis superior tomax.
clamp()
clamp a number between two values.
ts
function clamp(min: number, n: number, max: number): number;
min: minimum value.max: maximum value.value: number to be clamped.
throws when
minis superior tomax.
distance2D()
calculate a distance between two points in a 2D space.
ts
function distance2D(x1: number, y1: number, x2: number, y2: number): number;
x1: first point x coordinate.y1: first point y coordinate.x2: second point x coordinate.y2: second point y coordinate.
throws when one/more argument/s is/are not of type number.
distance3D()
calculate a distance between two points in a 3D space.
ts
function distance3D(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): number;
x1: first point x coordinate.y1: first point y coordinate.z1: first point z coordinate.x2: second point x coordinate.y2: second point y coordinate.z2: second point z coordinate.
random()
generate a random number in a given interval.
ts
function random(min: number, max: number, float?: boolean): number;
min: minimum value.max: maximum value, exclusive.float: allow float values.falseby default.
throws when one/more argument/s is/are not of type number. > throws when
minis greater thanmax.