Marching squares
Algorithm for generating contour lines on a 2D scalar field
Algorithm for generating contour lines on a 2D scalar field
In computer graphics, marching squares is an algorithm that generates contours for a two-dimensional scalar field (rectangular array of individual numerical values). A similar method can be used to contour 2D triangle meshes. The contours can be of two kinds: Isolines – lines following a single data level, or isovalue. Isobands – filled areas between isolines. Typical applications include the contour lines on topographic maps or the generation of isobars for weather maps. Marching squares takes a similar approach to the 3D marching cubes algorithm: Process each cell in the grid independently. Calculate a cell index using comparisons of the contour level(s) with the data values at the cell corners. Use a pre-built lookup table, keyed on the cell index, to describe the output geometry for the cell. Apply linear interpolation along the boundaries of the cell to calculate the exact contour position.
Open boosters, collect cards and trade them. Free to play.
Play for free