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

Username:   Password: 
 RegisterRegister   
 simple trig functions in turing
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mazer




PostPosted: Mon Oct 07, 2002 9:53 am   Post subject: simple trig functions in turing

just some simple use of trigonometry functions in turing for you lucky arses that got to take comp sci before grade ten when you're supposed to learn trig. show this to your classmates that can't do things like this and then call them n00bs as they watch in amazement. j00 r teh l337 now!

code:

% learn trig in grade 10 mathematics
include a real programming language
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Oct 07, 2002 10:38 am   Post subject: (No subject)

Hey Mazer, cool effect! 8)

Thx for sharing your code with us
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DonQuixote




PostPosted: Thu May 27, 2004 4:56 pm   Post subject: (No subject)

could anybody explain this code line for line ?
Especially the
code:

for i : 1 .. 5
    angle (i) := 72 * i
end for

loop
    for i : 1 .. 5
        ballx (i) := round (cosd (angle (i)) * hyp)
        bally (i) := round (sind (angle (i)) * hyp)
        angle (i) += 10
part?
I was planning to do something similar... but had absolutely no idea...
Mazer




PostPosted: Thu May 27, 2004 5:02 pm   Post subject: (No subject)

DonQuixote wrote:
could anybody explain this code line for line ?
Especially the
code:

for i : 1 .. 5
    angle (i) := 72 * i
end for

loop
    for i : 1 .. 5
        ballx (i) := round (cosd (angle (i)) * hyp)
        bally (i) := round (sind (angle (i)) * hyp)
        angle (i) += 10
part?
I was planning to do something similar... but had absolutely no idea...

That's alot more than one line but...

code:

for i : 1 .. 5
    angle (i) := 72 * i
end for

That just sets the angle for each ball (so they'll be evenly spaced).

code:

ballx (i) := round (cosd (angle (i)) * hyp)
bally (i) := round (sind (angle (i)) * hyp)

That's the trig portion. The ball's x coordinate is the cosine of it's angle multiplied by hyp, it's hypotenuse (the distance from the middle). Same for y coordinate, just with sine.

Man, old post. And your avatar is big, let's change that please.
netninja




PostPosted: Wed Sep 15, 2004 5:53 pm   Post subject: (No subject)

completely useless:
code:
if angle (i) = 360
                then
            angle (i) :=  i
        end if
AsianSensation




PostPosted: Wed Sep 15, 2004 6:24 pm   Post subject: (No subject)

what makes you say that?

the original code is
code:

        if angle (i) = 360
                then
            angle (i) := 72 * i
        end if


So it means, when one rotation is completed, the initial angle is resetted to one of the five spots.
Mazer




PostPosted: Wed Sep 15, 2004 6:29 pm   Post subject: (No subject)

A long time ago in a galaxy far far away, I'm sure I meant to use that as protection from integer overflow. Though it should've been angle (i) >= 360.

But thanks for bringing that up, I'm sorry if I scarred your learning of trigonometry. Please see signature.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: