
-----------------------------------
Mazer
Mon Oct 07, 2002 9:53 am

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!


% learn trig in grade 10 mathematics
include a real programming language


-----------------------------------
Tony
Mon Oct 07, 2002 10:38 am


-----------------------------------
Hey Mazer, cool effect! 8) 

Thx for sharing your code with us

-----------------------------------
DonQuixote
Thu May 27, 2004 4:56 pm


-----------------------------------
could anybody explain this code line for line ?
Especially the 

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
Thu May 27, 2004 5:02 pm


-----------------------------------
could anybody explain this code line for line ?
Especially the 

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...


for i : 1 .. 5 
    angle (i) := 72 * i 
end for 

That just sets the angle for each ball (so they'll be evenly spaced).


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
Wed Sep 15, 2004 5:53 pm


-----------------------------------
completely useless: if angle (i) = 360
                then
            angle (i) :=  i
        end if


-----------------------------------
AsianSensation
Wed Sep 15, 2004 6:24 pm


-----------------------------------
what makes you say that?

the original code is 
        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
Wed Sep 15, 2004 6:29 pm


-----------------------------------
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.
