p5art

Motion with Sine and Cosine

There are two math functions from trig that we can use to create motion, sin() and cos().

Both these functions will return a number between -1 and 1. We can use this value is so many different ways to create motion.

Sine and Cosine

In this video we can see how to use sin() and cos() to move a shape back and forth.

Here is the completed code, try changing the values to see how the motion changes. Link to code example

Circular Motion

In this video we see how using cos() to update the x value and sin() to update the y value can create circular motion.

Here is another code example. See how changing the values can change the motion. Link to code example