Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
simple trig functions in turing
Author Message
Mazer

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

Tony

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

Hey Mazer, cool effect! 8)

Thx for sharing your code with us
Tony's programming blog. DWITE - a programming contest.
DonQuixote

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

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

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

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

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 7 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: