code/__HELPERS/maths.dm
/proc/get_angle | Calculate the angle between two points and the west|east coordinate |
---|---|
/proc/get_pixel_angle | for getting the angle when animating something's pixel_x and pixel_y |
/proc/get_line | Get a list of turfs in a line from starting_atom to ending_atom . |
/proc/display_power | Format a power value in W, kW, MW, or GW. |
/proc/display_joules | Format an energy value in J, kJ, MJ, or GJ. 1W = 1J/s. |
/proc/display_energy | Format an energy value measured in Power Cell units. |
/proc/anyprob | chances are 1:value. anyprob(1) will always return true |
/proc/bit_count | counts the number of bits in Byond's 16-bit width field, in constant time and memory! |
/proc/make_tuple | Returns the name of the mathematical tuple of same length as the number arg (rounded down). |
DEG_TO_RAD | Multiplier for converting degrees to radians |
RAD_TO_DEG | Multiplier for converting radians to degrees |
Frand | A random real number between low and high inclusive |
Ceil | Value or the next integer in a positive direction: Ceil(-1.5) = -1 , Ceil(1.5) = 2 |
Ceilm | Value or the next multiple of divisor in a positive direction. Ceilm(-1.5, 0.3) = -1.5 , Ceilm(-1.5, 0.4) = -1.2 |
Ceilp | Value or the nearest power of power in a positive direction: Ceilp(3, 2) = 4 , Ceilp(5, 3) = 9 |
Floor | Value or the next integer in a negative direction: Floor(-1.5) = -2 , Floor(1.5) = 1 |
Floorm | Value or the next multiple of divisor in a negative direction: Floorm(-1.5, 0.3) = -1.5 , Floorm(-1.5, 0.4) = -1.6 |
Round | Value or the nearest integer in either direction |
Roundm | Value or the nearest multiple of divisor in either direction |
Percent | The percentage of value in max, rounded to places: 1 = nearest 0.1 , 0 = nearest 1 , -1 = nearest 10, etc |
IsInteger | True if value is an integer number. |
IsPowerOfTwo | True if value is a non-negative integer that is 0 or has a single bit set. 0, 1, 2, 4, 8 ... |
IsEven | True if value is an integer that is not zero and does not have the 1 bit set |
IsOdd | True if value is an integer that has the 1 bit set. |
IsMultiple | True if value is a multiple of divisor |
IsInRange | True if value is between low and high inclusive |
Csc | The cosecant of degrees |
Sec | The secant of degrees |
Cot | The cotangent of degrees |
/proc/Atan2 | The 2-argument arctangent of x and y |
/proc/Interpolate | Returns a linear interpolation from a to b according to weight. weight 0 is a, weight 1 is b, weight 0.5 is half-way between the two. |
/proc/Mean | Returns the mean of either a list or variadic arguments: Mean(list(1, 2, 3)) = 2 , Mean(1, 2, 3) = 2 |
/proc/VecSquareMag | Returns the euclidian square magnitude of a vector of either a list or variadic arguments: VecSquareMag(list(1, 2, 3)) = 14 , VecSquareMag(1, 2, 3) = 14 |
/proc/VecMag | Returns the euclidian magnitude of a vector of either a list or variadic arguments: VecMag(list(3, 4)) = 5 , VecMag(3, 4) = 5 |
FAHRENHEIT | Converts kelvin to farenheit |
Define Details
Ceil
Value or the next integer in a positive direction: Ceil(-1.5) = -1 , Ceil(1.5) = 2
Ceilm
Value or the next multiple of divisor in a positive direction. Ceilm(-1.5, 0.3) = -1.5 , Ceilm(-1.5, 0.4) = -1.2
Ceilp
Value or the nearest power of power in a positive direction: Ceilp(3, 2) = 4 , Ceilp(5, 3) = 9
Cot
The cotangent of degrees
Csc
The cosecant of degrees
DEG_TO_RAD
Multiplier for converting degrees to radians
FAHRENHEIT
Converts kelvin to farenheit
Floor
Value or the next integer in a negative direction: Floor(-1.5) = -2 , Floor(1.5) = 1
Floorm
Value or the next multiple of divisor in a negative direction: Floorm(-1.5, 0.3) = -1.5 , Floorm(-1.5, 0.4) = -1.6
Frand
A random real number between low and high inclusive
IsEven
True if value is an integer that is not zero and does not have the 1 bit set
IsInRange
True if value is between low and high inclusive
IsInteger
True if value is an integer number.
IsMultiple
True if value is a multiple of divisor
IsOdd
True if value is an integer that has the 1 bit set.
IsPowerOfTwo
True if value is a non-negative integer that is 0 or has a single bit set. 0, 1, 2, 4, 8 ...
Percent
The percentage of value in max, rounded to places: 1 = nearest 0.1 , 0 = nearest 1 , -1 = nearest 10, etc
RAD_TO_DEG
Multiplier for converting radians to degrees
Round
Value or the nearest integer in either direction
Roundm
Value or the nearest multiple of divisor in either direction
Sec
The secant of degrees