DevTools Logo

Convex Hull Algorithm Visualizer

Convex Hull Algorithm Visualizer

Compare Graham scan and Jarvis march step by step, entirely in your browser

Point set

Click the canvas to add points.

About

Explore accepted and rejected turns, stack state, collinear edge handling, and hull highlighting for two classic computational geometry algorithms. Everything runs client-side.

Examples

Square with an interior point

Input
grahamScan([{0,0}, {4,0}, {4,4}, {0,4}, {2,2}, {1,0}])
Output
hull 4 corners; {1,0} rejected as collinear interior

Edge-collinear points pop off the stack so only true corners survive.

All-collinear degeneracy

Input
grahamScan([{0,0}, {1,1}, {2,2}, {3,3}])
Output
hull [{0,0}, {3,3}] with collinear rejections

With no area, the hull collapses to the two extreme endpoints.

About this tool

Convex Hull Visualizer computes bounding polygons with grahamScan(points), jarvisMarch(points), and convexHull(points, algorithm = 'graham'): each returns a counter-clockwise hull plus a steps log (consider/accept/reject/wrap/complete with reasons and stack snapshots). At least 3 distinct points are required, duplicates are removed, and collinear edge interiors are dropped in favor of farther endpoints.

Graham scan sorts by polar angle around the lowest pivot and pops right turns or collinear interiors; Jarvis march gift-wraps from the leftmost point, preferring the most counter-clockwise (then farther) candidate. Both report deterministic, repeatable step sequences for the same input.

generateRandomPoints(seed, count = 20, width = 600, height = 400) emits browser-safe seeded points via an LCG (1664525/1013904223): the same seed and dimensions always match, different seeds diverge.

How to use this tool

  1. Supply 3+ distinct points

    Provide at least three unique coordinates — fewer throws an explicit 3-distinct-points error.

  2. Run Graham, Jarvis, or both

    Pick the algorithm (or compare both) and read the hull vertex list counter-clockwise.

  3. Step through decisions

    Walk the steps: consider/accept shows the frontier, reject names right turns versus collinear interiors.

  4. Seed random sets for demos

    Use generateRandomPoints with a fixed seed for a reproducible classroom point cloud.

Use cases

Teaching scan vs march

Contrast polar-angle sorting against gift-wrapping on the same set — same vertex set, different decisions.

Explaining collinear handling

Show why nearer edge points are rejected and only farther endpoints are kept.

Generating deterministic demos

Seed a point cloud once and replay the identical hull animation every run.

Common mistakes

Mistake:Expecting collinear edge points to survive.

Fix:Collinear interiors are intentionally popped (cross <= 0) — only the farthest endpoint on each edge stays.

Mistake:Passing fewer than 3 distinct points.

Fix:Duplicates are collapsed first, so three entries with only two unique locations still throws — add a genuinely distinct point.

Mistake:Assuming hull order is input order.

Fix:Output is counter-clockwise from the pivot/leftmost start, not the order you supplied.

Frequently asked questions

What does this tool do?

It computes counter-clockwise hulls with grahamScan, jarvisMarch, and convexHull(points, algorithm), each returning hull plus a consider/accept/reject/wrap/complete steps log — plus seeded generateRandomPoints(seed, count, width, height) clouds that reproduce exactly.

What happens with collinear or duplicate points?

Duplicates are removed first and you need 3 distinct points or it throws; collinear edge interiors are rejected (cross <= 0) so only farther endpoints survive — an all-collinear set collapses to its two extremes.

Is my point data uploaded or stored?

No. Sorting, wrapping, and seeded generation run entirely in your browser.

Do Graham scan and Jarvis march agree?

Yes on the vertex set — same counter-clockwise hull, reached by different decisions (polar-angle pops versus gift-wrapping comparisons), which the step logs make visible.

References & standards

.env Secret Safety Linter

Validate .env syntax and spot likely leaked credentials or placeholder secrets.

.htaccess Generator

Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

2D Fluid Dynamics & Particle Physics Sandbox

A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

AI Function Calling Schema Generator

Generate function calling JSON schemas from TypeScript interfaces

Algorithm Arena & Data Structure Visualizer

Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

Ansible Playbook Generator

Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML