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_nbt gets the sine and cosine of the angle, and returns it in storage phi.mathfunc:temp sin and storage phi.mathfunc:temp cos respectively
  • phi.mathfunc:sin_cos_score gets the sine and cosine of the angle, and returns it in $phi.mathfunc.sin temp and $phi.mathfunc.cos temp respectively with a scale of 2147483647

arctan2

  • phi.mathfunc:neg_atan2_nbt calculates the negative arctan2 of the two inputs. This function stores the result in storage phi.mathfunc:temp angle. The first input is storage phi.mathfunc:temp y, which corresponds to the y input to the normal atan2 function. The second input is storage phi.mathfunc:temp x, which corresponds to the x input of the normal atan2 function. Note that the inputs must be double, not float or 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 possible
  • phi.mathfunc:atan2_score is the same as phi.mathfunc:neg_atan2_nbt except the result is stored in $phi.mathfunc.angle with a scale of -11930464, which negates it to get the real result