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

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```