Discuss Scratch

SpiderJulian
Scratcher
7 posts

How do You even use Sin and cos?

I should know this right know, But I don't!
How do you even use SIN AND COS?
ScolderCreations
Scratcher
1000+ posts

How do You even use Sin and cos?

I don't know that well, but they are mathematical functions that are extremely useful once you figure out what they do. To put it simply, they create numbers that loop repeatedly when the number you're putting into them increases over time.
SpiderJulian
Scratcher
7 posts

How do You even use Sin and cos?

.

Last edited by SpiderJulian (April 9, 2022 20:57:10)

SpiderJulian
Scratcher
7 posts

How do You even use Sin and cos?

.

Last edited by SpiderJulian (April 9, 2022 20:57:38)

Za-Chary
Scratcher
1000+ posts

How do You even use Sin and cos?

Here is a project that showcases using sin and cos to achieve smooth “wiggling” motion: https://scratch.mit.edu/projects/290528099/
Tetris3DS
Scratcher
500+ posts

How do You even use Sin and cos?

SpiderJulian wrote:

I should know this right know, But I don't!
How do you even use SIN AND COS?
don't be ashamed if you don't know what sine & cosine is;

but I'll just do a quick rundown of what they acually are (Note: these are just to get a better understanding of sin and cos (and some fun facts), it isn't important to remember or understand them.):
  • sin/cos stand for “sine” and “cosine” (mathematicians being lazy with that “sin(e)” XD)
  • from a just an angle, there is no 100% way (or math formula) to do sine/cosine

Last edited by Tetris3DS (April 9, 2022 21:14:06)

Tetris3DS
Scratcher
500+ posts

How do You even use Sin and cos?

someone just sent a post as soon as i-
k0d3rrr
Scratcher
1000+ posts

How do You even use Sin and cos?

You can use sine to make sine waves!
Example:
when green flag clicked
reset timer
forever
set y to ((0) + ((25) * ([sin v] of ((180) * (timer)))))
end
ajsya
Scratcher
1000+ posts

How do You even use Sin and cos?

Za-Chary wrote:

Here is a project that showcases using sin and cos to achieve smooth “wiggling” motion: https://scratch.mit.edu/projects/290528099/
Here are a couple of other cool projects using sin and cos:

https://scratch.mit.edu/projects/625661869/
https://scratch.mit.edu/projects/673201324/
Nezon
Scratcher
1000+ posts

How do You even use Sin and cos?

Search trigonometry.

Learn trigonometry.

Wait until you’re in high school because you’re confused by trigonometry.
E_Equals_EmCeCube3
Scratcher
1000+ posts

How do You even use Sin and cos?

If you were learning about the trigonometric functions sine (sin), cosine (cos), and tangent (tan) for the first time, this is probably how they would teach you about it.

Let's suppose you have a right-angled triangle, that is, a triangle where one of its angles is a 90° angle. And let's say that you know the size of one of the other angles. Let's call this angle A.
Now label each of the three sides of the triangle as follows:
  • The side opposite of A as opposite.
  • The longest side; the one opposite the right angle, as hypotenuse.
  • The remaining side as adjacent.
Here's an example from the Scratch Wiki:


Then we have these relationships:
  • sin(A) = (length of opposite) / (length of hypotenuse)
  • cos(A) = (length of adjacent) / (length of hypotenuse)
  • tan(A) = (length of opposite) / (length of adjacent)

For example, if A is 50°, the hypotenuse had a length of 20 units, and you want to know the length of the opposite side, then you would apply the sine function and substitute in the known numbers, like this:

sin(50°) = (length of opposite) / 20

Then after a bit of rearranging…

length of opposite = 20 * sin(50°)
set [opposite v] to ((20) * ([sin v] of (50)))



Another useful application of the sine and cosine functions is demonstrated in the projects linked by @Za-Chary and @ajsya above, as well as the script shown by @k0d3rrr. Here the sine function allows you to simulate an oscillatory wavelike motion (referred to as “simple harmonic motion” by mathematicians and physicists). I'd even say that I personally use trig functions in my projects for this purpose more frequently than the one above!

For example:
forever
set y to ((40) * ([sin v] of (((360) / (2)) * (timer))))
end
Here, the number 40 is the amplitude of the motion; the maximum distance from the median point to the peak.
The number 2 is the period of the motion; it tells you that the motion repeats indefinitely every 2 seconds.
360 is a constant here (don't change it).

If all that's kinda confusing, I encourage you to play around with the script in a project and change the numbers to see how it affects the motion.

In any case, I hope you learned something new today.
banana124790
Scratcher
51 posts

How do You even use Sin and cos?

Cos is short for cosine and sin is short for sine.

([cos] of (your number here))
([sin] of (your number here))

Powered by DjangoBB