Learn creative coding writing simple programs

68. Circular motion reviewed

A review of how we create a circular motion. We make x = 100 + cos(a) * 200, and y = 120 + sin(a) * 200. In this example, (100, 120) is the center of the circle. The radius of the circle is 200. That's the distance from the center of the circle to the circle itself. And we use sine and cosine to calculate the points in the circle. The variable "a" is the angle, that means how much are we rotating around the center. If "a" is 0, we are at the right side of the center. As we increase "a", we rotate around the center. When "a" reaches 6.28 we have completed one full rotation around the center. That number is actually two times a special number called PI. When you are interested in making one complete turn around the center you can use a variable called TWO_PI, which is more precise than just typing 6.28. If you plan to keep spinning around the center then you don't need to know about PI or TWO_PI.

Tags: sine, cosine, circular, motion, animation

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus