module Math

Extended Modules

Defined in:

libgodot/types/math.cr

Class Method Summary

Class Method Detail

def self.clamp(val : Float32, min_val : Float32, max_val : Float32) : Float32 #

Clamps a value between min and max.


def self.clamp(val : Float64, min_val : Float64, max_val : Float64) : Float64 #

def self.deg_to_rad(deg : Number) : Float64 #

Converts degrees to radians.


def self.is_equal_approx(a : Float64, b : Float64, tolerance : Float64 = 0.00001) : Bool #

Returns true if two floating point values are approximately equal within tolerance.


def self.is_zero_approx(a : Float64, tolerance : Float64 = 0.00001) : Bool #

Returns true if a floating point value is approximately zero within tolerance.


def self.lerp(from : Float32, to : Float32, weight : Float32) : Float32 #

Linearly interpolates between from and to by weight.


def self.lerp(from : Float64, to : Float64, weight : Float64) : Float64 #

def self.move_toward(from : Float32, to : Float32, delta : Float32) : Float32 #

Moves from toward to by the given delta amount, never exceeding to.


def self.move_toward(from : Float64, to : Float64, delta : Float64) : Float64 #

Moves from toward to by the given delta amount with 64-bit precision, never exceeding to.


def self.rad_to_deg(rad : Number) : Float64 #

Converts radians to degrees.


def self.snapped(val : Float64, step : Float64) : Float64 #

Snaps a floating point value to the nearest multiple of step.


def self.wrapf(value : Float64, min_val : Float64, max_val : Float64) : Float64 #

Wraps a floating point number between min and max.