Discuss Scratch

flynn2019pw
Scratcher
55 posts

Sine and Cosine Help

Nearly every awesome project i've seen has sine or cosine in it. I get how it draws a triangle, but how does it draw it? does it draw it to the corner, edge, angle, mouse… I can't figure it out.

“What do you mean ‘timeline’? Time isn't made of lines. It's made of circles. That is why clocks are round” - Caboose from R vs. B
drmcw
Scratcher
1000+ posts

Sine and Cosine Help

They don't draw anything, they just relate the angles of a right angled triangle to the lengths of it's sides.
http://en.wikipedia.org/wiki/Trigonometry

You could think of them as ways to map between polar and cartesian coordinates.

Last edited by drmcw (May 27, 2014 21:03:04)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
bobbybee
Scratcher
1000+ posts

Sine and Cosine Help

More specifically, the sine of angle θ (theta) is the points on a circle represented as a 1D line (cosine is sine of θ-90 degrees).

A point on a circle is equal to (sin θ, cos θ) in Cartesian coordinates.

You can draw a unit circle by setting pen down, looping from zero to 360 and moving to designated coordinate for that value of theta, then finally taking pen up.

Play with it!

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
flynn2019pw
Scratcher
55 posts

Sine and Cosine Help

drmcw wrote:

They don't draw anything, they just relate the angles of a right angled triangle to the lengths of it's sides.
http://en.wikipedia.org/wiki/Trigonometry

You could think of them as ways to map between polar and cartesian coordinates.
So how does Scratch know the length of the triangle's sides to relate to the angles?

“What do you mean ‘timeline’? Time isn't made of lines. It's made of circles. That is why clocks are round” - Caboose from R vs. B
drmcw
Scratcher
1000+ posts

Sine and Cosine Help

flynn2019pw wrote:

drmcw wrote:

They don't draw anything, they just relate the angles of a right angled triangle to the lengths of it's sides.
http://en.wikipedia.org/wiki/Trigonometry

You could think of them as ways to map between polar and cartesian coordinates.
So how does Scratch know the length of the triangle's sides to relate to the angles?
You tell it! If you have an angle and one side then you can calculate the other sides using trigonometry or by having 2 sides you can calculate the angles, look at the Wikipedia link, that has more info than I could type here.

As an example this project http://scratch.mit.edu/projects/11178361/ moves a sprite in an arc as it knows the length of the pendulum and it's angle it can use trigonometry to calculate the x and y coordinates for the sprite.

Last edited by drmcw (May 27, 2014 21:55:16)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
flynn2019pw
Scratcher
55 posts

Sine and Cosine Help

Oh, Okay! I remember something about this I learned a while ago….. triangle's angles determine it's side ratios, so a right triangle with an angle of 45 and 45 will equal out to about .59 when the opposite is divided by the hypotenuse. Thanks!

“What do you mean ‘timeline’? Time isn't made of lines. It's made of circles. That is why clocks are round” - Caboose from R vs. B

Powered by DjangoBB