Friday, August 3, 2012

Fixing a Hole

My previous "plates on a sphere" simulation tended make continents that were too round. This was because of how I tried to resolve an issue stemming from my whole approach to the spherical geometry.

The sphere is divided into "tiles" of approximately equal size, each with a fixed location (a vector on the unit sphere). So at any point in time, a continent is defined as a set of those tiles.

When a continent moves, the vectors of all of its tiles are moved (that is, rotated around an axis) by a given amount; then the closest tile to each of those resulting vectors gets the value of its source tile.

Because of how the tiles are distributed (near the equator, almost a grid; at the poles, not anything like a grid), there is never a neat 1-to-1 mapping of source to destination tiles (unless the continent is centered on the equator, moving due West or East).

Which means there are lots of instances of more than one source tile mapping to the same destination tile, and tiles that are visibly part of the continent in its final position but that weren't mapped to by any source tile, and thus appear as holes.

My previous solution to this problem had been, at each step, to map each source tile to the nearest two destination tiles; to prevent the continent from growing out of control, I then trimmed off a bunch of tiles, starting with those most distant from the middle of the continent. This caused the progressive roundening, which sort of makes intuitive sense (sharp edges ground down over time) but doesn't look very realistic (Earth has lots of pointy continents).

My new strategy is to identify potential holes (tiles adjacent to those identified as belonging to the continent in its new position but that aren't themselves part of the continent's set of tiles), and rotate their positions backwards to see if the nearest tile to that location was part of the old set. If so, then add it to the new set, then check the tiles adjacent to that one, and so forth.

The resulting continents are much more satisfyingly pointy:


No comments: