What Lattice Points Are
A Lattice Point Calculator helps you count points with integer coordinates. In 2D, a lattice point is any point (x, y) where both x and y are integers. Examples include (0,0), (3,−2), and (10,7). Lattice points are central in geometry, number theory, discrete math, and computational geometry because they connect continuous shapes with integer structure.
Counting Lattice Points on a Line Segment
If a segment has endpoints with integer coordinates, the number of lattice points on the segment (including endpoints) can be found using the greatest common divisor:
Points = gcd(|x₂−x₁|, |y₂−y₁|) + 1
This works because the step vector between consecutive lattice points along the segment is the reduced direction vector: (Δx/g, Δy/g) where g = gcd(|Δx|,|Δy|). The calculator shows both g and the step vector so you can see the structure clearly.
Rectangle Grid Counting
For axis-aligned rectangles with integer min/max boundaries, counting lattice points becomes a grid problem. If x ranges from x_min to x_max (inclusive), there are (x_max−x_min+1) integer x values. Similarly for y. Multiply to get total points:
Total = (|x_max−x_min| + 1)(|y_max−y_min| + 1)
The tool also breaks the rectangle count into boundary points and interior points, which is useful when comparing with polygon methods and Pick-style reasoning.
Polygons and Pick’s Theorem
For a simple polygon whose vertices are lattice points, you can count boundary lattice points by applying the gcd method to every edge and summing the results (with correct endpoint handling). Then Pick’s Theorem connects the area A to interior points I and boundary points B:
A = I + B/2 − 1
This calculator computes the polygon area using the shoelace formula, computes B from edge gcd values, and then solves for I. If the polygon is self-intersecting, Pick’s Theorem does not apply in its standard form, so the tool warns you.
Lattice Points in a Circle
Counting integer points in a circle is a classic discrete geometry problem. There is no single simple closed form for general r, but an efficient approach is to iterate integer x values inside the bounding box and count how many integer y values satisfy:
(x−cₓ)² + (y−cᵧ)² ≤ r²
The calculator can report the number of points inside/on the circle and the number exactly on the boundary (where equality holds). If the radius is small, it can list points. For larger radii, it returns counts without listing every coordinate to keep performance stable.
Why gcd Appears in Lattice Geometry
The gcd method is one of the most important shortcuts in lattice counting. If you move from one integer point to another along a straight line, the number of integer steps you can take before reaching the endpoint is controlled by the greatest common divisor of the coordinate differences. This is why gcd shows up in segment counting, polygon boundary counting, and many proofs in lattice geometry.
Limitations and Practical Notes
Lattice counting is exact when the inputs are integers. For polygon counts using Pick’s Theorem, the polygon must be simple (non-self-intersecting) and have integer vertices. For circles, the tool uses enumeration; very large radii can be computed, but listing all points is intentionally limited to prevent huge outputs in the browser.
FAQ
Lattice Point Calculator – Frequently Asked Questions
Common questions about integer-coordinate points, gcd segment counting, Pick’s Theorem, and circle lattice counts.
A lattice point is a point in the plane (or space) whose coordinates are all integers, such as (3, −2) or (0, 0).
For endpoints (x1,y1) and (x2,y2) with integer coordinates, the number of lattice points on the segment (including endpoints) is gcd(|x2−x1|, |y2−y1|) + 1.
Pick’s Theorem relates a simple lattice polygon’s area A to its interior lattice points I and boundary lattice points B: A = I + B/2 − 1.
Yes. For simple polygons with integer vertices, it computes boundary points using the gcd-per-edge method and uses area + Pick’s Theorem to estimate interior lattice points.
No. Pick’s Theorem requires a simple (non-self-intersecting) polygon. The calculator warns if the polygon appears self-intersecting.
For an axis-aligned rectangle with integer corners and side lengths dx and dy, the number of lattice points inside/on the rectangle is (dx+1)(dy+1).
A circle lattice count is usually computed by enumerating integer x values and counting integer y values satisfying x²+y² ≤ r². This calculator does that efficiently and can return counts inside and on the circle.
Boundary points lie on the edges of a shape. Interior points lie strictly inside the shape. For polygons, Pick’s Theorem uses both counts.
The gcd of coordinate differences gives the number of integer steps along a segment’s direction vector. It tells how many lattice points occur at equal step intervals along the segment.
Yes. Some modes can generate a table of points or per-row counts and export the results to CSV.