GodotMath

gdext.builtin.GodotMath
object GodotMath

Godot's scalar math helpers (core/math/math_funcs.h), in single precision like the engine's real_t. The math builtins are built on these, so their results match the engine's own implementations.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
GodotMath.type

Members list

Value members

Concrete methods

def abs(x: Float): Float
def acos(x: Float): Float
def asin(x: Float): Float
def atan(x: Float): Float
def atan2(y: Float, x: Float): Float
def bezierDerivative(start: Float, control1: Float, control2: Float, end: Float, t: Float): Float
def bezierInterpolate(start: Float, control1: Float, control2: Float, end: Float, t: Float): Float
def ceil(x: Float): Float
def clamp(x: Float, min: Float, max: Float): Float
def clamp(x: Int, min: Int, max: Int): Int
def cos(x: Float): Float
def cubicInterpolate(from: Float, to: Float, pre: Float, post: Float, weight: Float): Float
def cubicInterpolateInTime(from: Float, to: Float, pre: Float, post: Float, weight: Float, toT: Float, preT: Float, postT: Float): Float

Barry-Goldman cubic interpolation with explicit knot times.

Barry-Goldman cubic interpolation with explicit knot times.

Attributes

def degToRad(deg: Double): Double
def floor(x: Float): Float
def fmod(x: Float, y: Float): Float

C fmod: the result has the sign of x.

C fmod: the result has the sign of x.

Attributes

def fposmod(x: Float, y: Float): Float

Math::fposmod: like fmod, but the result has the sign of y.

Math::fposmod: like fmod, but the result has the sign of y.

Attributes

def isEqualApprox(a: Float, b: Float): Boolean
def isEqualApprox(a: Float, b: Float, tolerance: Float): Boolean
def isFinite(x: Float): Boolean
def isZeroApprox(x: Float): Boolean
def lerp(from: Float, to: Float, weight: Float): Float
def lerpAngle(from: Float, to: Float, weight: Float): Float
def pow(x: Float, y: Float): Float
def radToDeg(rad: Double): Double
def round(x: Float): Float

std::round: halfway cases round away from zero.

std::round: halfway cases round away from zero.

Attributes

def sign(x: Float): Float

SIGN: 1, -1 or 0.

SIGN: 1, -1 or 0.

Attributes

def sign(x: Int): Int
def sin(x: Float): Float
def snapped(value: Float, step: Float): Float

Math::snapped: round to the nearest multiple of step (0 = no-op).

Math::snapped: round to the nearest multiple of step (0 = no-op).

Attributes

def snapped(value: Int, step: Int): Int

Math::snapped for integers (computed in double, truncated back).

Math::snapped for integers (computed in double, truncated back).

Attributes

def sqrt(x: Float): Float
def tan(x: Float): Float

Concrete fields

final val CmpEpsilon: 1.0E-5f
final val Pi: 3.1415927f
final val Tau: 6.2831855f
final val UnitEpsilon: 0.001f