Lattice Polygon Generator
Pick's theorem is one of the most satisfying results in elementary geometry: for any polygon whose corners sit on an integer grid, the area is the number of points strictly inside, plus half the number on the boundary, minus one. This generates such polygons, computes the area by the shoelace formula, counts the points directly, and shows both — so the theorem is demonstrated on your own figure rather than merely stated.
What this generator does
Draws vertices from an integer grid and orders them so the polygon never crosses itself, then computes the area by the shoelace formula and separately counts interior and boundary lattice points. Both figures are shown, and they must match.
How to use this tool
- Choose the grid size and how many corners the polygon should have.
- Generate, and read the area from the shoelace formula.
- Check the interior and boundary point counts against Pick's theorem.
- Try more vertices to see the theorem hold on shapes that are harder to eyeball.
Understanding the controls
- Grid size
- How far across the integer grid runs. A larger grid gives more spread-out polygons with more interior points to count.
- How many vertices
- Between 3 and 10 corners. More corners make the shape harder to judge by eye, which is exactly when counting points becomes the easier method.
- Seed
- Reproduces the same polygon, so a worked example can be handed to someone else and come out identically.
Common use cases
- Demonstrating Pick's theorem on figures nobody chose in advance
- Setting geoboard or dotty-paper exercises with checkable answers
- Practising area by counting rather than by formula
- Generating polygons for a coordinate geometry worksheet
- Showing that two very different methods give exactly the same area
How this generator works
Vertices are drawn at random from the grid and sorted by angle around their centroid, which usually gives a simple polygon — and it is then checked for self-crossing edges rather than assumed, because Pick's theorem only holds for polygons that do not cross themselves. The area comes from the shoelace formula. The boundary points come from the greatest common divisor of each edge's horizontal and vertical span, and the interior points are counted by testing every lattice point in the bounding box. Pick's theorem is then applied to those counts, and the two areas must agree exactly.
Randomness and fairness
Uses your browser's cryptographic random source to place the vertices by default. A seed switches to a reproducible sequence, which is deterministic and not cryptographically secure.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Only simple polygons are produced, since Pick's theorem does not hold for shapes that cross themselves or have holes.
- Vertices must sit exactly on the grid — the theorem says nothing about a polygon with one corner half way between points.
- Interior points are counted by scanning the bounding box, so a very large grid with many vertices will be slower.
- Angular sorting produces star-shaped polygons rather than every possible simple polygon on those points.
Privacy and your data
Everything is generated and counted in your browser, with nothing transmitted, stored or included in analytics.
Related generators
- Random Polygon GeneratorSimple polygons that never cross themselves, with the shoelace area, the perimeter and a convexity check.
- Coordinate Question GeneratorCoordinate questions built to order — quadrants, translations, reflections, midpoints, distances and a missing vertex — with worked steps.
- Area Question GeneratorArea questions built to order — rectangles, triangles, parallelograms, trapeziums and L-shapes — with worked steps and an answer key.
- Random Triangle GeneratorTriangles with sides, angles and area computed from the coordinates, and no slivers — every angle is at least 15 degrees.