Sunday 1 May 2011

Compression

This is a step forward from just having the waves speed up when you get closer to the center of the window. By declaring the radians (the distance between the highest box and the lowest box) in the line of code below as a variable called "compression" (also see below), we are able to use "dist" as a way to vary range of the distance between the highest box and the lowest box, i.e. the wave-lenght between the ripples.

int y = int(24 * cos(compression * distance(x,z,0,0) - a));

compression = (width/2-dist(mouseX,mouseY, width/2,height/2))/( dist(0,0, width/2, height/2));

It's saying that the radians will decrease from the center (width/2 and height/2) to the origin (0,0) in the window. In other words the waves will get more spaced out the closer the cursor gets to the sides of the window.

No comments:

Post a Comment