Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Clean0nion on November 17, 2013, 03:18:21 PM

Title: (solved) How do I use div when using radians?
Post by: Clean0nion on November 17, 2013, 03:18:21 PM
My script needs to convert degrees to radians accurately.
I was using
270 PI mul 180 div
then I found out that I need to use the quotient in the div.
As the quotient is what I'm trying to work out to use in SetImageRotation, how can I work out radians?

UPDATE: Fixed.
Self "main" GetImageRotation ->currentRotation
<-currentRotation <-mag_angle 270 PI mul 1 180 div mul sub 90 PI mul 1 180 div mul sub ->currentRotation
Self "main" <-currentRotation SetImageRotation
Title: Re: How do I use div when using radians?
Post by: eduran on November 17, 2013, 06:15:33 PM
To convert degrees to radians you need to divide by 360 and multiply by 2 pi. In CRPL:
asfloat(<-degrees) div(360) mul(PI) mul(2) ->radians
Title: Re: How do I use div when using radians?
Post by: Clean0nion on November 17, 2013, 06:47:08 PM
Quote from: eduran on November 17, 2013, 06:15:33 PM
To convert degrees to radians you need to divide by 360 and multiply by 2 pi. In CRPL:
asfloat(<-degrees) div(360) mul(PI) mul(2) ->radians
I did it like 270 PI mul 1 180 div mul
Because the problem with div is that it doesn't divide the numerator by the denominator, it divides the numerator by the quotient. And the quotient was the bit I was trying to work out.
numerator
                      =   quotient
denominator