YesNoOk
avatar

Pi (math) (Triggers) (Read 2333 times)

Started by Ricepigeon, September 15, 2015, 08:47:19 pm
Share this topic:
Pi (math) (Triggers)
New #1  September 15, 2015, 08:47:19 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
This trigger returns the numeric value of pi (3.141593...)

Format:
    pi
Arguments:
    none
Return type:
    float
Error conditions:
    none

Additional Notes:
Useful for the conversion of radians to degrees and vice versa, especially since the trigonometric triggers Sin, Cos, and Tan (and their respective counterparts Asin, Acos, and Atan) only utilize raidan values of angles, while SCTRLs such as Angleset and Angledraw only work with angles in degrees. As such, when using such triggers, its recommended to use Pi in the following manner:

Code:
[State 2000, Angle based velset]
type = velset
trigger1 = 1
x = 3.0*cos(fvar(0)*Pi/180.0)
y = -3.0*sin(fvar(0)*Pi/180.0)

In the above example, fvar(0) contains the value of our angle in degrees. Since the Cos and Sin triggers only accepts values of angles in radian form, multiplying the value of our angle by Pi and then dividing by 180.0 will convert our angle to radian form.

Code:
[State 2000, Angleset]
type = angleset
trigger1 = 1
value = Asin(1)*180.0/Pi

Similarly, the above state controller computes the value of Asin(1) in radians. To convert this value to degrees so that we can use it in the Angleset SCTRL, we multiply this value by 180 and then divide by Pi. In this example, this will give us the expected value of 90 degrees.
Last Edit: September 18, 2015, 02:49:02 pm by Just No Point