liveBook · Manning

Grid

As explained in Geometry for Programmers

A grid is a regularly spaced arrangement of cells or sample points used to organize geometric or numerical data.

A grid organizes values at regularly spaced positions. In geometric work, each cell or sample point gives an algorithm a finite, manageable view of a continuous shape, field, or image. The same layout can store scalar values, such as signed distances or pixel brightness, or coordinate data for a surface. section 8.2.2 section 11.3.2 section 12.4.2

For a parametric surface S(u, v) → (x, y, z), choose sampled u and v values over a UV square. Every pair (uᵢ, vⱼ) produces one 3D point, so the surface model becomes a two-dimensional point grid. A practical representation is three matching 2D arrays: one each for x, y, and z. section 8.2.2

Sampling a mushroom surface

A low-polygon mushroom starts with evenly spaced u and v samples from 0 to 1. One direction becomes an angle around the z-axis; the other follows a polynomial radius profile. Mesh-grid operations repeat the radius values across rows, pair v with angles, and compute x = r cos θ, y = r sin θ, and z = v. The resulting coordinate arrays provide the points later filled with triangles. section 8.2.2

A grid also supplies neighborhoods. In contouring an SDF, compare values in adjacent cells: a sign change between neighbors indicates that the target boundary passes between them. A finer grid generally gives a more accurate model, but increases both the number of cells to process and memory use. The initial cell-edge contour is useful as a scaffold, not a final smooth result. section 11.3.2 section 11.4.1

Grid-based contour construction proceeds in a simple sequence:

  • Classify cells from the sign of the SDF at their centers, then place contour segments along edges separating negative and positive neighboring cells. section 11.4.1
  • Move segment vertices toward the expected boundary using SDF values as error distances and the inverse gradient as direction. section 11.4.1
  • Use endpoint derivatives to turn straight segments into parametric cubic curves when a smoother contour is needed. section 11.4.1
Figure 12.20 An initial contour is a border between pixels with values below the threshold and above.
12-20

An image is already a grid of color values. Thresholding neighboring pixels creates short border segments wherever their values fall on opposite sides of the light/dark cutoff; this is a usable first contour but remains visibly pixel-based. section 12.4.2

How Geometry for Programmers covers it

How deep it goes
Develops coordinate-array construction and three-step contour refinement, while treating triangulation and later smoothing as separate work.
Examples
Demonstrates UV samples for a polynomial mushroom, SDF cell contours, and threshold borders between neighboring image pixels.
What it assumes
Assumes comfort with coordinate pairs and arrays while explaining grid sampling through concrete surface and cell examples.
What you can do after
Build it from scratch as sampled coordinate arrays or use it to form an initial contour from neighboring scalar values.
How it connects
Connects grids with parametric surfaces, triangle meshes, signed distance fields, gradients, cubic curves, and image vectorization.

Also explained in

Compare how 8 books explain grid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.