Discuss Scratch

KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

Trigonometry is a branch of mathematics that studies the relationship between the side lengths and angles of triangles.

Trigonometry (sometimes called trig) uses 3 basic formulas regarding the relationships between sides and angles of right triangles.



While it can seem complicated, trig can be used in Scratch projects to create really cool things like this and this.

Pretty cool huh? Well, using the

blocks, you can create some pretty cool stuff!

Play around with them! What sort of trig stuff can we come up with?



Information sourced from Wikipedia
Thanks to Firedrake969 and bubble103 for their projects
PoIygon
Scratcher
1000+ posts

trigonometry on scratch

well i already know you can make things go up and down smoothly using it
KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

PoIygon wrote:

well i already know you can make things go up and down smoothly using it
w a v y
RAMANRANJAN2282
Scratcher
500+ posts

trigonometry on scratch

Good idea
KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

RAMANRANJAN2282 wrote:

Good idea
Ok.
KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

bump
imfh
Scratcher
1000+ posts

trigonometry on scratch

Don't forget the atan function! It is really useful if you want to make a sprite point towards a specific spot without making it point at another sprite.

point towards ((x position) - (mouse x)) ((y position) - (mouse y)) // Note, might be backwards

define point towards (dx) (dy)
point in direction ([atan v] of ((dy) / (dx)))
if <(dy) < [0]> then
turn cw (180) degrees
end

Last edited by imfh (Sept. 28, 2021 15:24:38)

Vaibhs11
Scratcher
1000+ posts

trigonometry on scratch

mMmM yummy trig
I have made tons of junk trig projects, filled wave, circle, filled circle and even used trig for collabs (for smooth movement )
Vaibhs11
Scratcher
1000+ posts

trigonometry on scratch

wangat wrote:

PoIygon wrote:

well i already know you can make things go up and down smoothly using it
w a v y
mmm s m o o t h and m o i s t
KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

bump
han614698
Scratcher
1000+ posts

trigonometry on scratch

the most classic thing:
set [temp v] to [0]
forever
change y by ([cos v] of (temp)::operators)
change [temp v] by (6.3)
end
Vaibhs11
Scratcher
1000+ posts

trigonometry on scratch

han614698 wrote:

the most classic thing:
set [temp v] to [0]
forever
change y by ([cos v] of (temp)::operators)
change [temp v] by (6.3)
end
Yep, but a majority of users use sin.
han614698
Scratcher
1000+ posts

trigonometry on scratch

Vaibhs11 wrote:

han614698 wrote:

the most classic thing:
set [temp v] to [0]
forever
change y by ([cos v] of (temp)::operators)
change [temp v] by (6.3)
end
Yep, but a majority of users use sin.
I prefer cos.
awesome-llama
Scratcher
1000+ posts

trigonometry on scratch

han614698 wrote:

Vaibhs11 wrote:

han614698 wrote:

the most classic thing:
set [temp v] to [0]
forever
change y by ([cos v] of (temp)::operators)
change [temp v] by (6.3)
end
Yep, but a majority of users use sin.
I prefer cos.
I use whichever works. Depends on what you want to do when the input angle is 0. Sin is good if you want the start point to be 0 too.
Vaibhs11
Scratcher
1000+ posts

trigonometry on scratch

awesome-llama wrote:

han614698 wrote:

Vaibhs11 wrote:

han614698 wrote:

the most classic thing:
set [temp v] to [0]
forever
change y by ([cos v] of (temp)::operators)
change [temp v] by (6.3)
end
Yep, but a majority of users use sin.
I prefer cos.
I use whichever works. Depends on what you want to do when the input angle is 0. Sin is good if you want the start point to be 0 too.
Cosine is useful if you want it to be shifted 90° for some reason
Sheep_maker
Scratcher
1000+ posts

trigonometry on scratch

imfh wrote:

Don't forget the atan function! It is really useful if you want to make a sprite point towards a specific spot without making it point at another sprite.

point towards ((x position) - (mouse x)) ((y position) - (mouse y)) // Note, might be backwards

define point towards (dx) (dy)
point in direction ([atan v] of ((dx) / (dy)))
if <(dy) < [0]> then
turn cw (180) degrees
end
Isn't it dy/dx?

It sometimes throws me off that JavaScript's Math.atan2, which handles adding 180° if necessary, takes y then x, but I guess it makes sense because of this
imfh
Scratcher
1000+ posts

trigonometry on scratch

Sheep_maker wrote:

imfh wrote:

Don't forget the atan function! It is really useful if you want to make a sprite point towards a specific spot without making it point at another sprite.

point towards ((x position) - (mouse x)) ((y position) - (mouse y)) // Note, might be backwards

define point towards (dx) (dy)
point in direction ([atan v] of ((dx) / (dy)))
if <(dy) < [0]> then
turn cw (180) degrees
end
Isn't it dy/dx?

It sometimes throws me off that JavaScript's Math.atan2, which handles adding 180° if necessary, takes y then x, but I guess it makes sense because of this
Whoops, yep, you’re right.
KangaCoder
Scratcher
1000+ posts

trigonometry on scratch

ttt
gosoccerboy5
Scratcher
1000+ posts

trigonometry on scratch

Circular movement is cool
Vaibhs11
Scratcher
1000+ posts

trigonometry on scratch

gosoccerboy5 wrote:

Circular movement is cool
Funny triangle and vertex going around a circle and getting its x pos as sin and and y pos as cos
Trigonometry itself is cool

Powered by DjangoBB