Ahhhh yes…“sin” and “cos” are actually short for Sine and Cosine…a somewhat unsual but fun part of mathematics. Your math teacher is gonna be shocked when you show up to class knowing them like a boss. Which you totally can.
Sine and cosine relate the angles of a triangle to the lengths of its side. They turn out to be crazy useful as a way to draw or move in circles.
Check out this handy description to learn more: https://www.mathsisfun.com/sine-cosine-tangent.html
Now, here’s how to use them in Hopscotch. In this example we’re going to make Octo orbit around a sun:
1) We're going to set Octo's position to change as he orbits around the sun. So create a new rule with a "Set Position" block.
2) We're going to change his position using a new value, "Theta". It will refer to the angle between Octo and the sun. The starting point for this value assumes that Octo is to the right of the sun. At this point, the angle between him and the sun (Theta!) is 0 degrees. If he moves directly above the sun, he'd be 90 degrees above it (theta=90.) If he's directly to the left of the sun, theta would be 180. Does that make sense? So, first, create this new value called "theta".
3) In the x coordinate of the "Set Position" block, choose "Cosine" under the calculator. An equation will automatically populate, and in the bubble to the right of “cos”. Put in your new value “Theta" in it. The bubble to the left of cos (where the 100 is) tells you how much farther to the left or right Octo is from the center of the circle. That bubble to the right of "cos" sets the center of the circle. Here's a screenshot:
4) In the y coordinate of the "Set Position" block, choose "Sin" under the calculator. An equation will automatically populate, and in the bubble to the right of "sin", put in your new value "Theta". Here's a screenshot.
5) Put this set position block in a repeat forever.
6) Create a new rule that increases theta's value by 1. Put that in a repeat forever loop.
AAAAAAAAAND YOU’RE DONE! Now, watch Octo orbit!!
7) If you put the code with set position inside a “Leave a Trail” block, you'll then draw a circle behind octo as he moves.
8) Play around with the numbers to see how they change the height and width of the circle.
Phew. That was a lot. I’m tired. Are you? If you have other questions, reply with them! Play around with these blocks and you’ll be wowing the community (and your friends in math class) in no time.