Posted: Sun Jun 23, 2013 1:15 pm Post subject: Angles and trig
So I've been playing around with angles and I ran into a problem. This is my code:
Turing:
View.Set("offscreenonly") var lin1 :real var x, y, click :int var angle :real loop mousewhere(x, y, click)
lin1 :=sqrt(x ** 2 + y ** 2) if x =0then
angle :=90 else
angle :=arctand(y div x)%< this is the problem endif put"x = ", x
put"y = ", y
put"Length of line = ", lin1
put"Angle to x axis = ", angle
Draw.Line(0, 0, x, y, 7) View.Update cls endloop
When I put my mouse under 45 degrees, it just says it's at 0 degree. I'm not sure if this is something I'm doing wrong or if Turing is messing up.
Broken.png
Description:
This is what happens.
Filesize:
41.07 KB
Viewed:
110 Time(s)
Sponsor Sponsor
DemonWasp
Posted: Sun Jun 23, 2013 1:24 pm Post subject: RE:Angles and trig
Look up the definition of div in the Turing Help. Then, consider what happens when y = 197 and x = 300 (as in your picture).
chipanpriest
Posted: Sun Jun 23, 2013 1:28 pm Post subject: Re: RE:Angles and trig
DemonWasp @ Sun Jun 23, 2013 1:24 pm wrote:
Look up the definition of div in the Turing Help. Then, consider what happens when y = 197 and x = 300 (as in your picture).
Oh wow, thanks! I just replaced it with a "/" so it works with real numbers