API
API
C++
API reference (Math) — Alpha (1.14.2)

Defold Learn logo


Math

Math functions.

Namespace: dmMath
Include: #include <dmsdk/dlib/math.h>
FUNCTIONS
template <T> T Abs (T x) Abs function
template <T> T Clamp (T v, T min, T max) Clamp function
float DegToRad (float degrees) Convert degrees to radians
template <T> T Max (T a, T b) Max function
template <T> T Min (T a, T b) Min function
float RadToDeg (float radians) Convert radians to degrees
template <T> T Select (T x, T a, T b) Select one of two values

Functions

Abs

T Abs(T x)

Abs function

PARAMETERS

T x

RETURNS

T Absolute value of x

Clamp

T Clamp(T v, T min, T max)

Clamp function

PARAMETERS

T v Value to clamp
T min Lower bound
T max Upper bound

RETURNS

T Value closest to v inside the range [min, max]

DegToRad

float DegToRad(float degrees)

Convert degrees to radians

PARAMETERS

float degrees Angle in degrees

RETURNS

float Angle in radians

Max

T Max(T a, T b)

Max function

PARAMETERS

T a Value a
T b Value b

RETURNS

T Max of a and b

Min

T Min(T a, T b)

Min function

PARAMETERS

T a Value a
T b Value b

RETURNS

T Min of a and b

RadToDeg

float RadToDeg(float radians)

Convert radians to degrees

PARAMETERS

float radians Angle in radians

RETURNS

float Angle in degrees

Select

T Select(T x, T a, T b)

Select one of two values depending on the sign of another.

PARAMETERS

T x Value to test for positiveness
T a Result if test succeeded
T b Result if test failed

RETURNS

T a when x >= 0, b otherwise