1. Paths are generated by altering the 2nd-derivative of the x and y components. It's not as tricky as it sounds. A common way to simulate gravity (which has a constant acceleration, or second derivative) is to adjust position as follows.

x = x + dx; //just increasing x by the amount dx in each time step.

dx = dx + g; //just increasing dx (velocity) by a constant amount (acceleration) in each time step.

In the case here, the amount g changes sinusoidally (for no particular reason), making the paths wiggle around and do weird stuff. There's some more stuff in there (I forget why they sometimes just go straight), but remember - but there's no randomness in how the paths are made (they are deterministic). Click to start:

Click to stop the first one so it doesn't slow you down.

2. Similar idea as the first one, but this time not as smooth. The value g changes as the remainder when the time is divided by some value (modulus).

3. This time the x and y derivatives make zig-zag graphs, so the x and y positions are smooth curves (almost like sinusoids). I call these guys Lissajou Worms:

4. The last one got me thinking about Lissajou curves (x and y are sine functions of time), so I started with this:

Click to stop, and again to restart with new conditions. Watch the x position go all the way left, then all the way right, and the y position go all the way up and all the way down. So we have two functions to control position: x(t) = sin(b*t + c) and y(t) = sin(d*t), where b, c, and d are random above. When one of the periods is a multiple of the other one, you get a static shape like one of these.

We'll come back to this in a minute.

5. What would make these shapes more interesting? Both x and y have a constant amplitude, so maybe we should mix that up a bit. I added another component to the x function - now x(t) = f(t) + g(t), where f and g are both sine waves. Watch for y continuing to go all the way up and down, while x does more complicated stuff:

6. What would it look like if y were the sum of two waves as well? Well, it looks like craziness.

7. To tone down the craziness, I made sure the periods coincided better. Here, if

x(t) = f(t) + g(t)

y(t) = j(t) + k(t)

then the period of f is a multiple of j's period (or vice versa), and g and k have the same period. That way we get a periodic curve of some kind:

Click twice to get a new design. I hope you enjoyed your dose of math art!

[...] 10-minute math made some fantastic interactive flash math art. [...]

ReplyDelete