Learn creative coding writing simple programs

70. Slowly change the direction

We can use an angle to define in which direction we are moving an object. If we slowly change that angle, we smoothly change the direction too. In this episode we create a program that draws a line. The line is born at the center of the screen and moves toward a random initial direction. This direction slowly changes randomly. Sometimes it will be a quite straight line, other times it might turn around and go back where it was coming from. We achieve this by using sin() and cos() to calculate what is the next position according to the current position and the current direction.

Tags: direction, angle, sin, cos, Sine

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