Updated Geometry & Number Theory Tool

Lattice Point Calculator

Count lattice points with integer coordinates on line segments, polygon boundaries and interiors, as well as inside rectangles, circles and grids. Uses greatest common divisors, the shoelace formula and Pick’s theorem for exact integer geometry.

Segments & Boundaries Pick’s Theorem & Area Rectangles & Circles GCD-Based Geometry

Comprehensive Lattice Point & Integer Geometry Suite

This Lattice Point Calculator brings together the standard formulas from integer geometry: gcd-based counts on line segments, boundary and interior lattice points on polygons via the shoelace area formula and Pick’s theorem, rectangular and circular lattice point counts, grid generators and distance tools between lattice points.

For a line segment with endpoints \((x_1,y_1)\) and \((x_2,y_2)\) with integer coordinates, the number of lattice points on the closed segment is \[ N = \gcd(|x_2 - x_1|,\,|y_2 - y_1|) + 1. \]

For a polygon with vertices \((x_i,y_i)\) with integer coordinates, the number of lattice points on each edge from \((x_i,y_i)\) to \((x_{i+1},y_{i+1})\) is \[ \gcd\bigl(|x_{i+1} - x_i|,\,|y_{i+1} - y_i|\bigr), \] counting each vertex once overall, the total boundary count is \[ B = \sum_{i=1}^n \gcd\bigl(|x_{i+1} - x_i|,\,|y_{i+1} - y_i|\bigr), \] where \((x_{n+1},y_{n+1})=(x_1,y_1)\).

For a simple lattice polygon (vertices with integer coordinates, edges not crossing), Pick’s theorem states that \[ A = I + \frac{B}{2} - 1, \] where \(A\) is the area, \(B\) the number of lattice points on the boundary and \(I\) the number of interior lattice points. The area \(A\) is computed using the shoelace formula.

For a rectangle aligned with the coordinate axes and defined by real bounds \([x_{\min},x_{\max}]\) and \([y_{\min},y_{\max}]\), the number of lattice points with integer coordinates inside (including the boundary) is \[ N = \max\bigl(0,\,\lfloor x_{\max}\rfloor - \lceil x_{\min}\rceil + 1\bigr) \times \max\bigl(0,\,\lfloor y_{\max}\rfloor - \lceil y_{\min}\rceil + 1\bigr). \]

For a circle with center \((h,k)\) and radius \(r\), lattice points satisfy \[ (x - h)^2 + (y - k)^2 \le r^2 \] with \(x\) and \(y\) integers. This tab performs a direct search over integer candidates in a square bounding box around the circle.

Generate explicit lattice points in a rectangular grid region. This is useful for visualising small sets of lattice points or checking examples. To keep the list manageable, the calculator limits the total number of generated points.

A lattice point is a point in the plane whose coordinates are both integers. Here you can check whether a given point is a lattice point and optionally whether it lies inside a given rectangle.

For lattice points \((x_1,y_1)\) and \((x_2,y_2)\), the Euclidean distance is \[ d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}. \] The squared distance is always an integer; the distance itself is the square root of that integer.

Many lattice point formulas reduce to the greatest common divisor. For a vector \((\Delta x,\Delta y)\) joining two lattice points, the number of lattice points on the segment it spans is \[ N = \gcd(|\Delta x|,\,|\Delta y|) + 1. \] This tab gives quick access to the underlying gcd geometry.

Lattice Point Calculator – Integer Geometry with Segments, Polygons and Area

The Lattice Point Calculator on MyTimeCalculator is designed for problems where coordinates are restricted to integers. It combines greatest common divisors, polygon area formulas and Pick’s theorem to answer questions about how many lattice points lie on boundaries or in the interior of geometric shapes.

Lattice points naturally appear in coordinate geometry, discrete mathematics, number theory and contest problems. Counting them often reveals hidden arithmetic structure in seemingly simple shapes.

1. Lattice Points and the Integer Grid

A lattice point in the plane is a point of the form \((x,y)\) where both coordinates are integers. The set of all lattice points forms a regular square grid. Many geometric questions become number-theoretic when restricted to this grid, because distances and counts can often be expressed using greatest common divisors.

2. Line Segments and the GCD Formula

Consider a segment joining two lattice points \((x_1,y_1)\) and \((x_2,y_2)\). The step vector is \((\Delta x,\Delta y) = (x_2 - x_1, y_2 - y_1)\). Any lattice point on the segment must differ from \((x_1,y_1)\) by an integer multiple of the smallest step that still lands on the lattice.

\[ N = \gcd(|\Delta x|,\,|\Delta y|) + 1 \]

is the number of lattice points on the closed segment, including both endpoints. The calculator uses this formula both in the dedicated segment tab and internally when summing over polygon edges.

3. Polygon Boundary and the Shoelace Area Formula

For a polygon whose vertices are lattice points and are listed in order as \((x_1,y_1), (x_2,y_2), \dots, (x_n,y_n)\), the boundary lattice points can be counted edge by edge. On each edge from \((x_i,y_i)\) to \((x_{i+1},y_{i+1})\) the number of lattice points is

\[ \gcd\bigl(|x_{i+1}-x_i|,\,|y_{i+1}-y_i|\bigr). \]

Summing over all edges and closing the polygon with \((x_{n+1},y_{n+1})=(x_1,y_1)\) yields the boundary count \(B\).

The area of a simple polygon with vertices on the lattice can be computed by the shoelace formula:

\[ A = \frac{1}{2} \left| \sum_{i=1}^n x_i y_{i+1} - x_{i+1} y_i \right|, \quad (x_{n+1},y_{n+1})=(x_1,y_1). \]

This formula only requires the vertex coordinates and automatically handles both convex and concave polygons as long as they are simple (no self-intersections).

4. Pick’s Theorem and Interior Lattice Points

For a simple lattice polygon, Pick’s theorem relates area, boundary lattice points and interior lattice points:

\[ A = I + \frac{B}{2} - 1, \]

where:

  • \(A\) is the area of the polygon,
  • \(B\) is the number of lattice points on the boundary,
  • \(I\) is the number of lattice points strictly inside the polygon.

Given \(A\) and \(B\), the interior count is

\[ I = A - \frac{B}{2} + 1. \]

The calculator computes \(A\) via the shoelace formula, obtains \(B\) by summing gcd values along edges and then applies Pick’s theorem to report the interior lattice points.

5. Rectangles, Circles and Grid Regions

When a rectangle is aligned with the coordinate axes, lattice points inside it are simply integer pairs in a product of integer intervals. If the real bounds are \([x_{\min},x_{\max}]\) and \([y_{\min},y_{\max}]\), the integer \(x\)-coordinates run from \(\lceil x_{\min}\rceil\) to \(\lfloor x_{\max}\rfloor\), and similarly for \(y\).

For circles, there is no simple closed form valid for all radii. Instead, one usually searches over integer points in a square bounding box and checks whether they satisfy

\[ (x - h)^2 + (y - k)^2 \le r^2. \]

The circle tab implements this direct search with a limit on the radius to keep computations responsive. The grid generator tab similarly lists all integer pairs within a rectangular region, but caps the total number of points to avoid excessively long output.

6. Distances and GCD-Based Geometry

For lattice points \((x_1,y_1)\) and \((x_2,y_2)\), the squared distance

\[ d^2 = (x_2 - x_1)^2 + (y_2 - y_1)^2 \]

is always an integer. Some distances are themselves integers (perfect squares), while others remain square roots of integers. This is closely connected to Pythagorean triples and primitive vectors in the lattice.

The final tab highlights the central role of the greatest common divisor, showing how a vector \((\Delta x,\Delta y)\) can be decomposed into a primitive direction and a scale factor that directly counts lattice points on the corresponding segment.

Related Tools from MyTimeCalculator

Lattice Point Calculator FAQs

Frequently Asked Questions

Quick answers to common questions about counting lattice points, using gcd formulas, applying Pick’s theorem and interpreting the results from this calculator.

A lattice point is a point in the plane whose coordinates are both integers, usually written as \((x,y)\) with \(x,y \in \mathbb{Z}\). These points form the familiar square grid on graph paper. Many discrete geometry questions restrict attention to such points, which allows the use of number-theoretic tools like greatest common divisors and Pick’s theorem.

The formula \(N = \gcd(|x_2 - x_1|, |y_2 - y_1|) + 1\) applies when both endpoints \((x_1,y_1)\) and \((x_2,y_2)\) are lattice points. It then counts all lattice points on the closed segment between them. If either endpoint is not a lattice point, the formula no longer applies directly and the calculator requires integer inputs for the segment tab.

Pick’s theorem applies to simple polygons whose vertices are lattice points and whose edges do not cross. The polygon may be convex or concave, but it must not self-intersect. Under those conditions, the area, boundary lattice points and interior lattice points satisfy the relation \(A = I + \tfrac{B}{2} - 1\). The calculator assumes these conditions when using Pick’s theorem and the shoelace formula together.

There is no simple closed formula for the exact number of lattice points inside a general circle, so the calculator performs a direct search over candidate integer points in a bounding box. The number of checked points grows roughly like the square of the radius, so a limit keeps the computation fast and prevents excessively long runs in a browser environment.

Yes. You can enter the segment endpoints, polygon vertices or bounding regions from a problem and compare the calculator’s counts of boundary and interior lattice points with your own work. It is still important to understand and show the underlying formulas, but the calculator is helpful for confirming numerical answers and exploring similar examples.