Computational Geometry Toolkit

Nine 2D geometry tools, each drawn on a canvas as you type. Find a polygon’s area, centroid and perimeter, test whether a point is inside, wrap points in a convex hull, intersect segments and circles, take a bounding box, inspect a Bézier curve, measure an SVG path and simplify a polyline.

Calculator Numbers & Math Updated Oct 3, 2026
How to Use
  1. Pick a tool: Area & properties, Point-in-polygon, Convex hull, Bounding box, Line ∩ line, Circle ∩ circle, Bézier inspector, SVG path math or Coordinate simplifier.
  2. Type points as x,y, one per line. Any list of numbers works: they are read in pairs.
  3. Segments are x1,y1 x2,y2 and circles cx cy r. The Bézier inspector takes 3 control points (quadratic) or 4 (cubic) and a value of t from 0 to 1; the simplifier takes a tolerance ε.
  4. Results update as you type, and the geometry view redraws the shape, the hull, the crossing points or the simplified line.
  5. The example chips below load a worked case, such as a concave polygon for the inside test or a GPS-like track to simplify.
Input
Polygon
Intersect
Curves
Simplify
Result

Geometry view

Area
—
Perimeter
—
Vertices
—
Orientation
—

Worked Example

The pentagon (0, 0), (5, 0), (5, 3), (2, 5), (0, 3). The shoelace terms xᵢyᵢ₊₁ − xᵢ₊₁yᵢ are 0, 15, 19, 6 and 0, which add to 40, so the area is 20 and, being positive, the corners run counter-clockwise. That checks: a 5 × 3 rectangle (15) plus a triangle with base 5 and height 2 (5). The perimeter is 5 + 3 + √13 + √8 + 3 = 17.433978, and the centroid is (2.458333, 2.041667).

Intersections. The segments (0, 0)–(6, 4) and (0, 4)–(6, 0) cross at (3, 2), halfway along each (t = u = 0.5). Two circles of radius 3 centred at (0, 0) and (4, 0) are 4 apart, so the chord between their crossings sits a = (9 − 9 + 16) ÷ 8 = 2 from the first centre, with half-length h = √(9 − 4) = √5: the crossings are (2, 2.236068) and (2, −2.236068).

The common mistake: listing the corners out of order. A 4 × 3 rectangle entered as (0, 0), (4, 0), (4, 3), (0, 3) has area 12. Entered as (0, 0), (4, 3), (4, 0), (0, 3), the edges cross in a bow-tie, the shoelace terms are 0, −12, 12 and 0, and the “area” comes out as 0.

Show Work

Enter points to see the working step by step.

Formulas

Shoelace area
A = ½ Σ (xᵢyᵢ₊₁ − xᵢ₊₁yᵢ); sign = winding direction
Polygon centroid
Cx = Σ (xᵢ + xᵢ₊₁)(xᵢyᵢ₊₁ − xᵢ₊₁yᵢ) ÷ 6A, likewise Cy
Segment intersection
P = P1 + t(P2 − P1); on both segments when 0 ≤ t, u ≤ 1
Circle intersection
a = (r₁² − r₂² + d²) ÷ 2d, h = √(r₁² − a²)
Cubic Bézier
B(t) = (1−t)³P₀ + 3(1−t)²t P₁ + 3(1−t)t² P₂ + t³P₃
Douglas–Peucker
keep the farthest point if its distance to the chord > ε, then recurse

Where the Algorithms Come From

The shoelace formula was described by Albrecht Ludwig Friedrich Meister in 1769 and by Carl Friedrich Gauss in 1795, which is why it is also called Gauss’s area formula. Bézier curves were developed at two French car makers at about the same time: Paul de Casteljau worked out the evaluation algorithm that bears his name at Citroën in 1959, and Pierre Bézier published the curves from his work at Renault in the early 1960s. They rest on the Bernstein polynomials that Sergei Bernstein introduced in 1912.

Computational geometry became a field of its own in the 1970s. Ronald Graham published his convex-hull scan in 1972 and A. M. Andrew the monotone-chain version used here in 1979; both run in O(n log n) time. Urs Ramer (1972) and, independently, David Douglas and Thomas Peucker (1973) published the line-simplification algorithm, which cartographers still use to reduce coastlines and tracks for smaller maps.

About This Tool

This toolkit covers the 2D calculations that graphics, CAD, GIS and game code keep needing, and draws every result so you can see whether it is right. It reports the details that usually cause bugs: the sign of an area (winding order), whether an intersection is on the segments or only on their extended lines, and how many points a simplification keeps. Curve lengths are measured along a fine polyline (240 pieces for a Bézier curve, 40 per SVG segment), and SVG arcs are approximated by their end points.

Everything runs in your browser; nothing is uploaded.

Related tools: Area Calculator, 3D Geometry / Vector Lab, and Triangle Calculator.

Frequently Asked Questions

How is the area of a polygon calculated?

With the shoelace formula: add xᵢyᵢ₊₁ − xᵢ₊₁yᵢ around the vertices and halve the total. For (0, 0), (5, 0), (5, 3), (2, 5), (0, 3) the terms are 0, 15, 19, 6 and 0, so the area is 40 ÷ 2 = 20. A positive result means the vertices run counter-clockwise, a negative one clockwise. The corners must be listed in order around the edge; the formula is only valid for a polygon whose edges do not cross.

Why is the centroid not the average of the corners?

The centroid is the balance point of the whole area, so each edge is weighted by the area it sweeps. For the pentagon above it is (2.458333, 2.041667), while the average of the five corners is (2.4, 2.2). The two agree only for special shapes such as triangles, rectangles and regular polygons.

Do two segments cross, or only the lines through them?

The tool finds where the infinite lines meet and reports the parameters t (along A) and u (along B). The segments themselves cross only when both are between 0 and 1. (0, 0)–(4, 4) and (0, 4)–(4, 0) cross at (2, 2) with t = u = 0.5. Shorten A to (0, 0)–(1, 1) and the lines still meet at (2, 2), but t = 2, so the tool says the crossing lies outside the segments.

How does the point-in-polygon test work?

It casts a ray from the point to the right and counts how many edges it crosses: an odd count means inside. It works for concave shapes too. In the polygon (0, 0), (6, 0), (6, 6), (3, 3), (0, 6), which has a V-shaped notch in the top, (3, 2) is inside and (3, 5) is outside, in the notch. A point lying exactly on an edge can be reported either way.

What does the tolerance ε do in the simplifier?

Douglas–Peucker keeps a point only if it lies more than ε from the straight line that would replace it. The 10-point track in the example keeps 5 points at ε = 0.3, (0, 0), (3, 0.05), (5, 4), (7, 0) and (9, 0), a 50% reduction; at ε = 0.05 it keeps 8. Choose ε in the same units as the coordinates: the largest wobble you are willing to lose.

How do I use the Computational Geometry Toolkit?

Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Does it cost anything or need an account?

No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.

Is anything I type uploaded?

No. The tool works entirely on your device, so the values you enter never leave your browser.

Common Use Cases

Plots and floor plans

The 5-corner shape (0, 0), (5, 0), (5, 3), (2, 5), (0, 3) encloses 20 square units.

GPS tracks

Thin a 10-point trace to 5 points at ε = 0.3 before drawing or storing it.

Game collision

Two circles of radius 3 with centres 4 apart cross at (2, ±2.236068).

Fonts and animation

The cubic Bézier (0, 0), (1, 4), (5, 4), (6, 0) passes through (3, 3) at t = 0.5 and is about 9.147 long.

Hit testing

Check whether a click at (3, 5) falls inside a concave outline.

Last updated: