This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » FAQ
  •  » how do I use sin. cos, and tan?

#1 2008-05-10 00:14:45

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

how do I use sin. cos, and tan?

Moderator Summary:
Sine (sin), cosine (cos), and tangent (tan) are trigonometric functions. They are useful in projects concerning direction. To read more about trigonometry you can view the wikipedia article here.

If you have further, specific questions about these blocks you can ask on this topic.

I have been taught in my algebra class how to use these formulas, but my math teacher didn't mention how to use the formulas on just numbers. So how do I use this formula?
because I still don't understand how I scroll in steps
                    /                          \   /                \
<change X by I sin of direction * 1 I * I speed * -1 I>
                    \                           /  \                /
                    /                           \    /              \
<change Y by I cos of direction * 1 I * I speed *-1 I>
                    \                            /  \               /

Last edited by demosthenes (2010-12-17 17:39:57)


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#2 2008-05-10 00:39:07

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

The trigonometry functions are functions not formulas. It is a lot to explain in trig so I would rather not go into detail.

What do you know about trig already? It shouldn't be too hard to figure out uses for trig if you have been learning it in school.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-05-10 00:40:03

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: how do I use sin. cos, and tan?

nothing, I'm 13, in 7th grade, I know algebra


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#4 2008-05-10 00:41:05

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: how do I use sin. cos, and tan?

I'm probably the youngest "good" scratcher on this website, oh yeah I learned scrolling in steps from you, so thanx


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#5 2008-05-10 00:42:53

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

Do you want me to write up a small lesson on trig? It might be a bit difficult for someone who is in 7th grade (and a lot to type out for me).


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2008-05-10 00:49:43

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: how do I use sin. cos, and tan?

I guess so, I really want to try understand sin, cos, and tan so I can make better games


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#7 2008-05-10 00:51:20

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: how do I use sin. cos, and tan?

one more thing, I posted a neat idea on multiplayer idea in "show and tell" you should see that, it's a pretty basic idea, I don't know why nobody thought of it yet, it's not code

Last edited by dingdong (2008-05-10 00:51:53)


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#8 2008-05-10 01:26:53

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

dingdong wrote:

I guess so, I really want to try understand sin, cos, and tan so I can make better games

To be honest it won't really help you that much but I'll try to explain anyways.

Trigonometry is a branch of mathematics that deals with triangles and right angled triangles in particular.

Sin is short for sine, tan is short for tangent, and cos is short for cosine.

All these are ratios between the sides of a triangle.

http://id.mind.net/~zona/mmts/trigonometryRealms/introduction/rightTriangle/trig3.gif


Tan is the ratio of the side opposite an angle to the side adjacent to an angle.
tan(B)=6/4

Cos is the ratio of the side adjacent to an angle to the hypotenuse.
cos(B)=4/7.21

Sin is the ratio of the side opposite an angle to the hypotenuse.
sin(B)=6/7.21

Example question:

In a right angled triangle the side opposite angle b is 3 and if angle b is 37 degrees then what size is the side adjacent to angle b?

tan(37)=3/adjacent

tan(37)= 0.753

0.753=3/adjacent

3/0.753= adjacent

3.984=adjacent

Rounded up adjacent = 4

Therefore the side adjacent to angle b is 4.


That is the very basics of trig. I am not very good with explaining math stuff so I am sorry if you don't understand it.

Last edited by archmage (2008-05-10 01:31:42)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#9 2008-05-10 01:29:37

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: how do I use sin. cos, and tan?

That's useful, and i kinda get it, since we just got done studying triangles and Pythagoreans Theorem and stuff


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#10 2008-05-10 01:40:22

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

Bluestribute wrote:

That's useful, and i kinda get it, since we just got done studying triangles and Pythagoreans Theorem and stuff

Yeah normally in programming you would the Pythagorean Theorem to find the distance between 2 points.

And you would normally use a formula to make a sprite point to a coordinate.
And you would normally use a formula to move a sprite in the direction it is facing.

But thanks to the distance to, point to, and move blocks scratch programmers don't have to worry about some of that complicated math stuff.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#11 2008-05-10 01:41:34

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: how do I use sin. cos, and tan?

archmage wrote:

Bluestribute wrote:

That's useful, and i kinda get it, since we just got done studying triangles and Pythagoreans Theorem and stuff

Yeah normally in programming you would the Pythagorean Theorem to find the distance between 2 points.

And you would normally use a formula to make a sprite point to a coordinate.
And you would normally use a formula to move a sprite in the direction it is facing.

But thanks to the distance to, point to, and move blocks scratch programmers don't have to worry about some of that complicated math stuff.

Wait, I can use the Pythagoreans Theorem? I don't wait...........


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#12 2008-05-10 01:49:06

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

Bluestribute wrote:

Wait, I can use the Pythagoreans Theorem? I don't wait...........

I made a challenge to people once if they could find distances using the Pythagoreans Theorem. Here is that thread http://scratch.mit.edu/forums/viewtopic.php?id=1802&p=2


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#13 2008-05-10 01:57:47

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: how do I use sin. cos, and tan?

I don't think I'm ready for that, since this is the first time understanding the trig blocks. I looked at it. Let me try to make a trig project. I'll post it here when I'm done.


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#14 2008-05-10 04:47:36

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: how do I use sin. cos, and tan?

archmage wrote:

dingdong wrote:

I guess so, I really want to try understand sin, cos, and tan so I can make better games

To be honest it won't really help you that much but I'll try to explain anyways.

Trigonometry is a branch of mathematics that deals with triangles and right angled triangles in particular.

Sin is short for sine, tan is short for tangent, and cos is short for cosine.

All these are ratios between the sides of a triangle.

http://id.mind.net/~zona/mmts/trigonome … /trig3.gif


Tan is the ratio of the side opposite an angle to the side adjacent to an angle.
tan(B)=6/4

Cos is the ratio of the side adjacent to an angle to the hypotenuse.
cos(B)=4/7.21

Sin is the ratio of the side opposite an angle to the hypotenuse.
sin(B)=6/7.21

Example question:

In a right angled triangle the side opposite angle b is 3 and if angle b is 37 degrees then what size is the side adjacent to angle b?

tan(37)=3/adjacent

tan(37)= 0.753

0.753=3/adjacent

3/0.753= adjacent

3.984=adjacent

Rounded up adjacent = 4

Therefore the side adjacent to angle b is 4.


That is the very basics of trig. I am not very good with explaining math stuff so I am sorry if you don't understand it.

I think I understand it, although I'm in 6th grade and don't have algebra yet... I just have no idea of how I can use those functions in a Scratch project. -_-


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#15 2008-05-10 06:01:27

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

Re: how do I use sin. cos, and tan?

MyRedNeptune wrote:

I think I understand it, although I'm in 6th grade and don't have algebra yet... I just have no idea of how I can use those functions in a Scratch project. -_-

Let's say you have a sprite moving across the screen, and it's rotating as well.  You want another sprite to move with it and appear to be attached to it.  Maybe you are trying to make a mechanical arm of some sort, with an upper arm, forearm, and wrist sections, maybe like in my project Power Shovel 1.0 (hint hint).  If all the sprites share the same origin, the problem is pretty simple, you just have all the parts Go To the main sprite. 

But if the attached sprites are NOT at the same origin (maybe because they are rotating as well, then trig is very handy for calculating where they need to be and locating them there.

http://scratch.mit.edu/projects/Paddle2See/62394

Take a look at Power Shovel (link above) and look at the positioning logic for the Forearm and Thumb sprites.  Trig is used to position both of those sprites so they appear to all be attached, yet they don't share an origin and they all can rotate independently.


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

Offline

 

#16 2008-05-10 06:36:11

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

Re: how do I use sin. cos, and tan?

archmage wrote:

dingdong wrote:

I guess so, I really want to try understand sin, cos, and tan so I can make better games

To be honest it won't really help you that much but I'll try to explain anyways.

Trigonometry is a branch of mathematics that deals with triangles and right angled triangles in particular.

Sin is short for sine, tan is short for tangent, and cos is short for cosine.

All these are ratios between the sides of a triangle.

http://id.mind.net/~zona/mmts/trigonome … /trig3.gif


Tan is the ratio of the side opposite an angle to the side adjacent to an angle.
tan(B)=6/4

Cos is the ratio of the side adjacent to an angle to the hypotenuse.
cos(B)=4/7.21

Sin is the ratio of the side opposite an angle to the hypotenuse.
sin(B)=6/7.21

Example question:

In a right angled triangle the side opposite angle b is 3 and if angle b is 37 degrees then what size is the side adjacent to angle b?

tan(37)=3/adjacent

tan(37)= 0.753

0.753=3/adjacent

3/0.753= adjacent

3.984=adjacent

Rounded up adjacent = 4

Therefore the side adjacent to angle b is 4.


That is the very basics of trig. I am not very good with explaining math stuff so I am sorry if you don't understand it.

Thanks! I won't be doing sin, cos and tan until 2 years time in school, so that's really useful. I love maths (and I find it really easy) but though I understand the basics of all that, it's quite hard because I've learnt most of that vocabulary in French (been here almost 2 years, now), not English, so although I'd know the french word for it, I don't actually know what the English word means!


Be nice, I'm an old lady  wink

Offline

 

#17 2008-05-10 13:34:21

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: how do I use sin. cos, and tan?

crud! that's exactly what I learned and I still don't get it! you're teaching me thg exact same thing! I guess I just don't understand it


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#18 2008-05-10 18:07:02

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

Re: how do I use sin. cos, and tan?

dingdong wrote:

crud! that's exactly what I learned and I still don't get it! you're teaching me thg exact same thing! I guess I just don't understand it

Yeah. I know what you mean. Staring at triangles doesn't help much, sometimes. What are needed are some projects that are interactive and show you what sin and cos "feel" like. Once you get a foothold, it will get a lot easier.

I think there may be some projects that fit the bill; I'll take a look.

Offline

 

#19 2008-05-10 18:14:07

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: how do I use sin. cos, and tan?

chalkmarrow wrote:

dingdong wrote:

crud! that's exactly what I learned and I still don't get it! you're teaching me thg exact same thing! I guess I just don't understand it

Yeah. I know what you mean. Staring at triangles doesn't help much, sometimes. What are needed are some projects that are interactive and show you what sin and cos "feel" like. Once you get a foothold, it will get a lot easier.

I think there may be some projects that fit the bill; I'll take a look.

I get it. Not how to use it, but what it is


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#20 2008-05-10 21:56:00

jwiens
Scratcher
Registered: 2007-10-17
Posts: 39

Re: how do I use sin. cos, and tan?

Cos, Sin and Tan areused to tell te distance in relation to one another <when green flag clicked><forever><if><(cos of Sprite 1<=>#)<move(10)steps>

Offline

 

#21 2008-05-10 22:39:42

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how do I use sin. cos, and tan?

jwiens wrote:

Cos, Sin and Tan areused to tell te distance in relation to one another <when green flag clicked><forever><if><(cos of Sprite 1<=>#)<move(10)steps>

I don't understand what you mean. Perhaps you could elaborate?


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#22 2008-05-11 02:46:20

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: how do I use sin. cos, and tan?

My "planet Staker" game uses the trig functions to allow blocks to rotate around a central point that is not their own centre of rotation.

They are used to calculate how far vertically and horizontally a given block must move in order to appear to be rotating around a given point, based on their distance from that point and the change in angle (how many degrees it turns).


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#23 2008-05-11 05:33:08

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: how do I use sin. cos, and tan?

Paddle2See wrote:

MyRedNeptune wrote:

I think I understand it, although I'm in 6th grade and don't have algebra yet... I just have no idea of how I can use those functions in a Scratch project. -_-

Let's say you have a sprite moving across the screen, and it's rotating as well.  You want another sprite to move with it and appear to be attached to it.  Maybe you are trying to make a mechanical arm of some sort, with an upper arm, forearm, and wrist sections, maybe like in my project Power Shovel 1.0 (hint hint).  If all the sprites share the same origin, the problem is pretty simple, you just have all the parts Go To the main sprite. 

But if the attached sprites are NOT at the same origin (maybe because they are rotating as well, then trig is very handy for calculating where they need to be and locating them there.

http://scratch.mit.edu/projects/Paddle2See/62394

Take a look at Power Shovel (link above) and look at the positioning logic for the Forearm and Thumb sprites.  Trig is used to position both of those sprites so they appear to all be attached, yet they don't share an origin and they all can rotate independently.

Oh, thanks Paddle2See! ^^ I guess I understand it, a little. Well, at least I got a grip at it!  big_smile


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#24 2008-05-17 14:52:04

piplupquaza
Scratcher
Registered: 2008-02-19
Posts: 73

Re: how do I use sin. cos, and tan?

dingdong wrote:

I'm probably the youngest "good" scratcher on this website, oh yeah I learned scrolling in steps from you, so thanx

How old are u then? just wondering PS im 11<next costume>


http://www5d.biglobe.ne.jp/~aoi-k/scribble/scrib251.gif Look at the little dudes dance!!! 
Ultimate game for sonic fans here: http://scratch.mit.edu/projects/piplupquaza/143340

Offline

 

#25 2008-05-18 19:14:22

Bobby500
Scratcher
Registered: 2008-04-19
Posts: 1000+

Re: how do I use sin. cos, and tan?

Yeah, trig stuff is complicated. BTW, Archmage, I wanted to explain it!

Delving into more complicated stuff ( tell me if I messed it up, been a while since I used it.) I will now explain how to use it for finding sides on any triangle.

All you need are 2 sides and the angle in between them. This will get you the length of the other opposite side.

http://illuminations.nctm.org/Lessons/LawSinesCosines/LawSines-TriangleABC.jpg

Okay, I am useing this triangle for refence.

The Law of sines is:
a             c
------ =--------
sinA     SinC

Okay, lets say side a=20, c=14 and C=40 degrees.

Okay now the formula is
20        14
-----=-------
SinA    Sin40

Or 12.8557 (20*Sin40) = 14 SinA
Divide the 14
.9182=SinA
Now we do Sin-1(.9182)
Angle A equals 66.6

I have no clue on how to use this in scratch. Writing this out just made me feel samrt.

Offline

 
  • Index
  •  » FAQ
  •  » how do I use sin. cos, and tan?

Board footer