Maths Functions - MinecraftPhi/MinecraftPhi-modules GitHub Wiki
pow
phi.mathfunc:pow calculates $phi.mathfunc.pow.base raised to the power of $phi.mathfunc.pow.exp. These two numbers are assumed to be integers, and the exponent is in the range 0..31. Numbers outside this range will set $phi.mathfunc.pow.success to 0 and not calculate the power. The result is stored in $phi.mathfunc.pow.result
is_pow_2
phi.mathfunc:is_pow_2 determines whether the absolute value of $phi.mathfunc.value temp is a power of 2 or not. Stores false(0)/true(1) in $phi.mathfunc.is_pow_2 temp
sine and cosine
The sine and cosine of storage phi.mathfunc:temp angle can be calculated with a few different functions.
Note that the angle must be a float, not a double or other data type
phi.mathfunc:sin_cos_nbtgets the sine and cosine of the angle, and returns it instorage phi.mathfunc:temp sinandstorage phi.mathfunc:temp cosrespectivelyphi.mathfunc:sin_cos_scoregets the sine and cosine of the angle, and returns it in$phi.mathfunc.sin tempand$phi.mathfunc.cos temprespectively with a scale of 2147483647
arctan2
phi.mathfunc:neg_atan2_nbtcalculates the negative arctan2 of the two inputs. This function stores the result instorage phi.mathfunc:temp angle. The first input isstorage phi.mathfunc:temp y, which corresponds to the y input to the normal atan2 function. The second input isstorage phi.mathfunc:temp x, which corresponds to the x input of the normal atan2 function. Note that the inputs must bedouble, notfloator any other datatype. This returns the negative of the result because of the internal details of the implementation, and will not change unless NBT operations become possiblephi.mathfunc:atan2_scoreis the same asphi.mathfunc:neg_atan2_nbtexcept the result is stored in$phi.mathfunc.anglewith a scale of -11930464, which negates it to get the real result