Math Functions

From Danmakufu Wiki
Jump to: navigation, search

min

Arguments:
 1) value 1
 2) value 2

Returns the lesser of the two values.

max

Arguments:
 1) value 1
 2) value 2

Returns the greater of the two values.

log

Arguments:
 1) value

Returns the natural (base e) logarithm of the value.

log10

Arguments:
 1) value

Returns the common (base 10) logarithm of the value.

cos

Arguments:
 1) angle

Returns the cosine of the angle. Cosine is a value between -1 and 1 that corresponds to the x-value in a coordinate plane.

sin

Arguments:
 1) angle

Returns the sine of the angle. Sine is a value between -1 and 1 that corresponds to the y-value in a coordinate plane.

tan

Arguments:
 1) angle

Returns the tangent of the angle. Tangent is the slope of the line created by the angle (x/y).

acos

Arguments:
 1) value

Returns the arccosine of the angle. acos(cos(x)) = x, if x is between 0 and 180.

asin

Arguments:
 1) value

Returns the arcsine of the value. asin(sin(x)) = x, if x is between -90 and 90.

atan

Arguments:
 1) value

Returns the arctangent of the value. atan(tan(x)) = x, if x is between -90 and 90.

atan2

Arguments:
 1) y
 2) x

Returns the arctangent of y/x, which is the angle from (0, 0) to (x, y). The angle will be in the range -180 < a <= 180, where a is the returned value. Useful for getting the angle from one point to another point. For example, the angle from the boss to the player is atan2(player y - boss y, player x - boss x).

rand

Arguments:
 1) minimum value
 2) maximum value

Returns a random value between the two values. Note that the random value is not an integer; if you need one, use either round(), ceil(), or floor() on the returned value.

round

Arguments:
 1) value

Returns the value as an integer. Values of 0.5 or greater are rounded up; otherwise they are rounded down.

truncate

Arguments:
 1) value

Returns the value with no decimal places. For instance, 1.123 becomes 1. The shortened name trunc can also be used to refer to this function.

ceil

Arguments:
 1) value

Returns the value rounded up to the next integer.

floor

Arguments:
 1) value

Returns the value rounded down to the next integer.

absolute

Arguments:
 1) value

Returns the value as an absolute number (if it is negative, it will be changed to a positive).

modc

Arguments:
 1) value
 2) value to divide the first value by

Returns a modulus of the first value. Modulus provides the remainder of the division (7 modulo 5 would be 2).

Note: unlike remainder, modc returns a value with the same sign as the dividend: modc(-7, 4) equals -3 and modc(7, -4) equals 3.

pi

Returns the value of pi.