ChaiLove API  0.28.0
Public Member Functions | Data Fields
love::math Class Reference

Provides system-independent mathematical functions. More...

Public Member Functions

float random (float min, float max)
 Get uniformly distributed pseudo-random number, between the given numbers. More...
 
mathsetRandomSeed (int min, int max)
 Sets the random seed to a random seed between the given min and max values. More...
 
mathsetRandomSeed (int seed)
 Sets the seed of the random number generator. More...
 
int getRandomSeed ()
 Gets the seed of the random number generator. More...
 
float rad (float degrees)
 Converts from degrees to radians. More...
 
float degrees (float rad)
 Converts from radians to degrees. More...
 

Data Fields

const float e = 2.718281828459045f
 Mathematic constant: e. More...
 
const float pi = 3.14159265358979323846f
 Mathematics constant: Pi. More...
 

Detailed Description

Provides system-independent mathematical functions.

Member Function Documentation

◆ degrees()

float love::math::degrees ( float  rad)

Converts from radians to degrees.

See also
love.math.rad

◆ getRandomSeed()

int love::math::getRandomSeed ( )

Gets the seed of the random number generator.

See also
love.math.setRandomSeed

◆ rad()

float love::math::rad ( float  degrees)

Converts from degrees to radians.

See also
love.math.degrees

◆ random()

float love::math::random ( float  min,
float  max 
)

Get uniformly distributed pseudo-random number, between the given numbers.

Parameters
min(0.0f) The minimum value.
max(1.0f) The max value.
Returns
A number between the two given min and max values.
love.math.random(5, 10) // 5-10
love.math.random(10) // 0-10
love.math.random() // 0.0f-1.0f

◆ setRandomSeed() [1/2]

math& love::math::setRandomSeed ( int  min,
int  max 
)

Sets the random seed to a random seed between the given min and max values.

Parameters
minThe lower 32 bits of the seed value.
maxThe higher 32 bits of the seed value.
Returns
The math module, to allow for method chaining.
See also
love.math.getRandomSeed

◆ setRandomSeed() [2/2]

math& love::math::setRandomSeed ( int  seed)

Sets the seed of the random number generator.

Parameters
seedThe integer number with which you want to seed the randomization.
Returns
The math module, to allow for method chaining.
See also
love.math.getRandomSeed

Field Documentation

◆ e

const float love::math::e = 2.718281828459045f

◆ pi

const float love::math::pi = 3.14159265358979323846f

Mathematics constant: Pi.

See also
https://en.wikipedia.org/wiki/Pi