This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-01-03 22:41:12

_Dragon_MC_
Scratcher
Registered: 2007-07-15
Posts: 12

Problem with the trig functions (degrees to radians and back)

**WARNING: HIGH-SCHOOL MATH CONTENT**

I'm in seventh grade. In my quest for more knowledge, I've been teaching myself trigonometry recently. The results so far are what I call a rudimentary knowledge of trig (I know how to make a circle, ellipse, figure-8 with sine and cosine, etc).

When the new version of Scratch was released, complete with trig functions, I was overjoyed. There are so many possibilities with even the simplest knowledge of trig: truly good rotating pseudo-3D diagrams, better Z-mapping, easier physics... but with the good comes the confusing.

I recently learned that functions in trigonometry take functions in radians (there are 2π radians in 360 degrees). I also learned that to convert degrees into radians, I need to multiply the angle in degrees by π/180 to get the angle in radians. I needed to know this to make a simple rotating rectangular 3D prism I was working on. So I made a constant that was equal to π/180. I would have a running variable that I used for sin and cos that would change by 1 each loop. I multiplied this by my constant, and got what definitely was not an ellipse. It was a short line that took up only a very small area at the center of the screen.

So, my question is this: Do the trig functions convert the value they're given to radians automatically? Or am I just doing something wrong?

Last edited by _Dragon_MC_ (2008-01-04 19:28:39)


Nine out of every two people don't understand fractions!

Offline

 

#2 2008-01-03 23:20:16

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Problem with the trig functions (degrees to radians and back)

Dragon_MC: That's awesome that you're that far advanced in 7th grade. The trig functions take an angle in degrees as their input, but Scratch angles (in terms of direction) are measured from the positive y-axis (going clockwise) rather than the usual way you learned in your texbook (i.e., from the positive x-axis). In any event, there is no need to convert to radians before calling the trig functions. If you change your constant to 1.0 it will probably work  smile

Last edited by chalkmarrow (2008-01-04 00:30:57)

Offline

 

#3 2008-01-04 03:54:32

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Problem with the trig functions (degrees to radians and back)

I'll just add to this that many computer languages do require input in radians.  Scratch is farily unusual (in my experience) in allowing input in degrees.  So keep that conversion constant handy...you may need it someday.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2008-01-04 06:26:24

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Problem with the trig functions (degrees to radians and back)

I think it was correct for the Scratch designers to use degrees rather than radians for both direction and the trig functions, as angles in degrees are taught much more commonly than radians, especially at the peak age for Scratch programmers (which seems to be 11-12 year olds).

I think it was a mistake for them to swap the x and y axes when defining direction, so that the default direction (+x) is 90 degrees instead of 0 degrees, and direction increases clockwise in Scratch, but counterclockwise in every other programming language and mathematics textbook.  Since Scratch is intended as an educational tool, arbitrarily changing the standard conventions is a bad idea.

Offline

 

#5 2008-01-04 09:33:12

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Problem with the trig functions (degrees to radians and back)

Yes, the odd choice of zero degrees aligning with the Y axis has messed me up a few times.  I have to use Sine where normally I would use Cosine to get X componenents.  But I do like that the positive Y direction is up rather than down as it is in many other graphic spaces I've worked in!  A coordinate system that aligned with the text books would be very nice.  It's probably too late to change it now though.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#6 2008-01-04 19:28:04

_Dragon_MC_
Scratcher
Registered: 2007-07-15
Posts: 12

Re: Problem with the trig functions (degrees to radians and back)

Oh, okay. One of the resources I used for learning trig was a book on XNA Game Studio something-or-other, which used C#. C# requires input in raadians, so I was just wondering.

I like that 0 degrees is vertical. I, on the other hand, am not used to the degree system having 0 degrees at the X axis. It just makes it easier for me  smile


Nine out of every two people don't understand fractions!

Offline

 

Board footer