Sunday, October 10, 2010

Livin' on a Sphere

I've been mucking about trying to get something that looks something like what's described here, but on the surface of a sphere (not about to try modeling any kind of actual fluid dynamics, just trying to mimic the behavior).

I used a sinusoidal projection so each screen pixel represents about the same area of the sphere. It took me way too long to figure out I should be using regular old vectors in R3 instead of muddling through with latitudes and longitudes.

Brighter green points are heavier, and the blue point is their weighted average. The red point repels the green points and moves to the blue point whenever the green ones slow down sufficiently.

So this is early in a cycle, when the red point has recently moved to the weighted average location:

Early in cycle, origin of impulse close to center of points.

And this is later on in a (later) cycle, as the repelled points are converging towards the antipode:

Later in the cycle, new center far from origin of impulse.

Source here ("" is shown, but there's other related crap in there), requires Numpy and pygame.

No comments: