Skip to content
roidrole edited this page Jul 23, 2025 · 3 revisions

Bunch of missing math methods.

Import :

import mods.ctutils.utils.Math;

Note : the type Number refers to any of double, float, int, and long. It is not used internally : methods are duplicated.

Unless otherwise stated, all Number parameters of a method must be the same

Method Accepted Types/Parameters Return Type Note
getE [None] double Returns the value of the mathematical constant e
getPi [None] double Returns the value of the mathematical constant π
getSqrt2 [None] double Returns the value of √2. Recommended over manual calc.
max Number, Number Number
min Number, Number Number
floor double long
ceil double long
round float int
round double long
clamp Number, Number, Number Number Clamps first between second and third
average Number[] float or double
abs Number Number Absolute value
sign Number Number Returns the sign of the input (-1, 0 or 1)
sin double double
cos double double
tan double double
asin double double arcsin (inverse sin)
acos double double arccos (inverse cos)
atan double double arctan (inverse tan)
sinh double double Hyperbolic sin
cosh double double Hyperbolic cos
tanh double double Hyperbolic tan
hypot double, double double Returns √(first²+second²) (hypotenuse of a right triangle with inputs as catheti)
sqrt double double Square Root, √input
cbrt double double Cube Root ³√input
fastInvSqrt double double Returns 1/√input. Way faster than calculating it separately. See
log input as double @Optional base as double double log in any base. Defaults to e.
log10 double double Decimal (base 10) log
exp exponent as double @Optional base as double double exponent in any base. Defaults to e.
random [None] Double Deprecated. Use Math.getRandom().nextDouble
getRandom @Optional seed as long IRandom

Clone this wiki locally