SS1984 - Modules - Types

code/__HELPERS/maths.dm

/proc/SolveQuadraticThe quadratic formula. Returns a list with the solutions, or an empty list if they are imaginary.
/proc/closer_angle_differenceFinds the shortest angle that angle A has to change to get to angle B. Aka, whether to move clock or counterclockwise.
/proc/gaussianConverts a uniformly distributed random number into a normally distributed one using the Box-Muller transform Since this method produces two random numbers, one is saved for subsequent calls (making the cost negligible for every second call) This will return +/- decimals, situated about mean with standard deviation stddev 68% chance that the number is within 1stddev 95% chance that the number is within 2stddev 98% chance that the number is within 3stddev...etc
/proc/get_overlapReturns a list where [1] is all x values and [2] is all y values that overlap between the given pair of rectangles
/proc/directional_bounded_sumAdjusts a value by a given amount while respecting specified bounds Prevents inadvertently increasing the value in the wrong direction when at bounds
/proc/sqrtor0Calculates the square root of a number, returning 0 for negative inputs to avoid runtime errors
/proc/round_downMARK: THIS DONT WORK!
/proc/get_angleCalculate the angle between two movables and the west|east coordinate
/proc/delta_to_angleCalculate the angle produced by a pair of x and y deltas
/proc/get_angle_rawAngle between two arbitrary points and horizontal line same as /proc/get_angle
/proc/normalize_angleGet normalized angle (for fix rotation animation bug near 90 and -90 degrees)
/proc/get_lineGet a list of turfs in a line from starting_atom to ending_atom.
/proc/display_joulesFormat an energy value in J, kJ, MJ, or GJ. 1W = 1J/s.
/proc/display_powerFormats a power value in W, kW, MW, or GW.
/proc/make_bit_tripletGenerates a bit triplet by selecting three unique numbers from 1 to 9 and setting corresponding bits Returns a number with three bits set based on the selected numbers
/proc/betweenEnsures a value is between a minimum and maximum, clamping it if necessary
/proc/dd_rangeClamps a number to the specified range