mixin std::Math

std::Math
abs

static extension Float abs(Float self)

Return the absolute value of this float. If this value is positive then return this, otherwise return the negation.

acos

static extension Float acos(Float self)

Return the arc cosine.

approx

static extension Bool approx(Float self, Float that, Float? tolerance := null)

Return if this Float is approximately equal to the given Float by the specified tolerance. If tolerance is null, then it is computed using the magnitude of the two Floats. It is useful for comparing Floats since often they lose a bit of precision during manipulation. This method is equivalent to:

if (tolerance == null) tolerance = min(abs(this/1e6), abs(r/1e6))
(this - r).abs < tolerance
asin

static extension Float asin(Float self)

Return the arc sine.

atan

static extension Float atan(Float self)

Return the arc tangent.

atan2

static extension Float atan2(Float y, Float x)

Converts rectangular coordinates (x, y) to polar (r, theta).

ceil

static extension Float ceil(Float self)

Returns the smallest whole number greater than or equal to this number.

clamp

static extension Float clamp(Float self, Float min, Float max)

Clip this float between the min and max. If its less than min then Clamp this float between the min and max. If its less than min then return min, if its greater than max return max, otherwise return this float itself.

cos

static extension Float cos(Float self)

Return the cosine of this angle in radians.

cosh

static extension Float cosh(Float self)

Return the hyperbolic cosine.

e

const static Float e := 2.718281828459045f

Float value for e which is the base of natural logarithms.

exp

static extension Float exp(Float self)

Return e raised to this power.

floor

static extension Float floor(Float self)

Returns the largest whole number less than or equal to this number.

log

static extension Float log(Float self)

Return natural logarithm of this number.

log10

static extension Float log10(Float self)

Return base 10 logarithm of this number.

max

static extension Float max(Float self, Float that)

Return the larger of this and the specified Float values.

min

static extension Float min(Float self, Float that)

Return the smaller of this and the specified Float values.

pi

const static Float pi := 3.141592653589793f

Float value for pi which is the ratio of the circumference of a circle to its diameter.

pow

static extension Float pow(Float self, Float pow)

Return this value raised to the specified power.

round

static extension Float round(Float self)

Returns the nearest whole number to this number.

sin

static extension Float sin(Float self)

Return sine of this angle in radians.

sinh

static extension Float sinh(Float self)

Return hyperbolic sine.

sqrt

static extension Float sqrt(Float self)

Return square root of this value.

tan

static extension Float tan(Float self)

Return tangent of this angle in radians.

tanh

static extension Float tanh(Float self)

Return hyperbolic tangent.

toDegrees

static extension Float toDegrees(Float radians)

Convert this angle in radians to an angle in degrees.

toRadians

static extension Float toRadians(Float degrees)

Convert this angle in degrees to an angle in radians.