Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Angles and trig
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chipanpriest




PostPosted: 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 = 0 then
        angle := 90
    else
        angle := arctand (y div x) %< this is the problem
    end if
    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
end loop



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:  82 Time(s)

Broken.png


Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: 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




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: