Apex › Storage & databases

Marching squares — grid of numbers to smooth contour

How you turn a scalar field (elevation, brightness, density) into the contour line where it equals a threshold — the coastline between above and below. Each cell's four corners give one of 16 cases; the contour crosses the edges separating an above corner from a below one, cut at the linear-interpolated crossing for smoothness. Every cell is independent (great for the GPU), and it's the 2-D sibling of marching cubes. Slide the threshold and watch the blobs merge.

More in Storage & databases