<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef" -->

---
title: Faster than earcut: triangulating 3.7M map polygons in...
description: A map engine's polygon triangulator has been released as earstrip, an ISC-licensed C++ and WebAssembly library with the same API as earcut. It triangulates...
canonical: https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Faster than earcut: triangulating 3.7M map polygons in 489 ms | daily.dev
og:description: A map engine's polygon triangulator has been released as earstrip, an ISC-licensed C++ and WebAssembly library with the same API as earcut. It triangulates...
og:url: https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef
og:image: https://api.daily.dev/og/posts/Ml3fqLeEF.png
og:image:alt: Faster than earcut: triangulating 3.7M map polygons in 489 ms
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Faster than earcut: triangulating 3.7M map polygons in 489 ms

**[Hacker News](https://daily.dev/sources/hn)** · 17 min read · 2 upvotes · 0 comments

## Summary

A map engine's polygon triangulator has been released as earstrip, an ISC-licensed C++ and WebAssembly library with the same API as earcut. It triangulates 3.74 million real map polygons in 489 ms natively, 14% faster than earcut.hpp, and 1.4 to 2.1 times as fast as earcut.js in the browser. The author rebuilt the ear clipper step by step, tracking each optimization's effect: testing only reflex vertices, skipping tests on convex polygons, writing triangle strips, bucketing dents, and branchless counting. On a world map polygon with 11,675 holes, earstrip takes 459 ms versus 2,892 ms for earcut.hpp.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://globus.software/blog/2026/10/16/cutting-map-polygons>

## Questions this post answers

### How much faster is earstrip than earcut.hpp for triangulating map polygons?

Earstrip triangulates 3.74 million real map polygons natively in C++ in 489 ms, compared to 557 ms for earcut.hpp, making it about 14% faster. In the browser via WebAssembly, earstrip is 1.4 to 2.1 times as fast as earcut.js depending on the calling pattern (loop inside the module versus per-polygon calls). On a polygon with 11,675 holes, earstrip takes 459 ms versus 2,892 ms for earcut.hpp.

_Comparing triangulation libraries for a map renderer? Track benchmarks like these on daily.dev before picking one._

### How do you handle polygon holes in ear clipping triangulation?

Each hole is cut open and stitched to the outer boundary with a bridge, an edge from a vertex of the hole to a vertex of the boundary walked once in each direction. The rightmost vertex of the hole casts a ray right; the first edge it hits determines a candidate bridge target, checked so the bridge triangle contains no other vertex, per David Eberly's write-up of ear clipping. Holes are bridged rightmost first so a hole further left can bridge into one already merged.

_Implementing geometry algorithms like hole-bridging? Keep reference breakdowns like this handy on daily.dev._

### What is a Delaunay triangulation and why is it useful?

A Delaunay triangulation is one where no point lies inside the circumscribed circle of any triangle's three corners, and among all triangulations of the same points it maximizes the smallest angle, avoiding needle-thin triangles. It's built incrementally by inserting vertices one at a time, splitting the triangle a point falls into, and flipping edges until the empty-circle rule holds again. 'Constrained' Delaunay forces the polygon's own edges to remain edges even where the circle rule would otherwise flip them.

_Choosing between Delaunay and ear-clipping triangulation for your renderer? Keep comparisons like this close on daily.dev._

## Community take

How the wider developer community reacted, aggregated from 1 discussion and 31 comments across hackernews (as of 2026-10-22).

**TL;DR:** The release is well received as a solid, well-documented optimization over earcut, with deep technical discussion around triangle quality, GPU rendering tradeoffs, and comparisons to Delaunay and other triangulation approaches; the earcut author himself engaged positively and praised specific optimizations.

**Sentiment:** 60% positive · 30% mixed · 10% skeptical

**The case for**

- The writeup and benchmarking methodology (one commit per idea, timed) were praised as excellent and thorough.
- The branch-free dent counting optimization was highlighted as a key reason it beats earcut and keeps the wasm build small (27KB gzipped).
- A user ran independent benchmarks comparing it to a Delaunay triangulator and found it clearly favored earstrip on their workload.
- The original earcut author engaged constructively, calling it a cool library and wanting to borrow tricks for earcut's JS version.

**The pushback**

- Several commenters noted the output contains many long, thin triangles, which are historically considered a worst case for GPU rasterizers and can cause shading artifacts or hurt systems like Unreal's Nanite.
- Delaunay triangulation produces more balanced triangles and is noted as a real quality tradeoff versus this library's speed-focused approach.
- One commenter questioned whether numbers without accompanying benchmarks against other libraries are meaningful.

**By community**

- hackernews (positive): Largely appreciative of the technical writeup and performance gains, with substantive debate on triangle quality and alternative algorithms rather than outright criticism.

**Hottest debate:** Whether favoring long, thin triangles for speed is actually a good tradeoff given their historically poor GPU rasterization and shading performance versus more balanced Delaunay-style output.

**Open questions**

- How does earstrip compare against other triangulators like iShape-rust/ioverlay or Seidel's trapezoidal method on real-world data?
- How much does the long, thin triangle topology actually impact real-world rendering performance?
- How big is the WASM build compared to earcut's JS bundle, and how does that tradeoff affect practical adoption?

**Highlights**

> Numbers without benchmarks are useless. :) During vector map generation we make sure that all data is valid. But our users can import custom GeoJSON layers and they could contain all sorts of self-intersections.   == world.bin   56472 polygons   whole file, best of 7: earstrip 453.4 ms, delaunay32 1696.9 ms   up to 4          14455 polygons: earstrip 0.3 ms, delaunay32 14.4 ms   5-8               8328 polygons: earstrip 0.6 ms, delaunay32 14.5 ms   9-32             18019 polygons: earstrip 6.8 ms, delaunay32 83.7 ms   33-256           13511 polygons: earstrip 66.6 ms, delaunay32 366.9 ms   257 and more      2159 polygons: earstrip 376.8 ms, delaunay32 1209.4 ms   delaunay32: rejected 3039 (by class 0/28/365/1671/975), empty outer ring 0, area off on 0 covered, 1930016 triangles   earstrip: exact 56338, constrained 134
> — [molind on hackernews · 1 comments](https://news.ycombinator.com/item?id=50195457)

> Hey Evgen, Earcut author here — thanks for the writeup and a really cool library! I need to see if there are any tricks to borrow for Earcut's JS version. :) One thing to note is that I deliberately had to reject some of the potential optimizations to keep the library small, so that bundle size doesn't blow up — for most practical applications (e.g. Mapbox GL JS), it's already fast enough (and 4.1k min/gz). Curious how big the WASM build of Earstrip is. On the C++ side, Mapbox now uses a hybrid approach where small polygons are processed with earcut.hpp, while big and complex polygon switch to a different algorithm based on monotone decomposition, because while it has higher constants in algorithmic complexity, it scales much better with input size.
> — [mourner on hackernews · 1 comments](https://news.ycombinator.com/item?id=50193710)

> I see that the result contains lots of very long, very thin triangles. Aren't those generally the worse case scenario for the GPU rasterizer?
> — [stymaar on hackernews · 1 comments](https://news.ycombinator.com/item?id=50197175)

> I've wondered for a long time why ear clipping + optimizations has won on triangulation over stuff like Seidel's trapezoidal method, which has O(nlog*n) time complexity and handles holes naturally. I know big-O isn't everything, but that's essentially linear versus quadratic, and it seems like we care about triangulating more and more complex polygons as time goes on. Is it just a triangle quality thing? Does Seidel lead to too many hard to deal with slivers?
> — [mistercow on hackernews · 1 comments](https://news.ycombinator.com/item?id=50196888)

> I'm not sure, but "This post is about how we got there.\nA GPU fills triangles and nothing else." is very Claude-ish.  So does "[I created] one commit per idea, and timed every commit on those same 3.7 million polygons, so each section below ends with a number."  And "A triangle needs no cutting at all". My experience is that Claude Opus 5 and 5.5 are very good at implementing optimizations, reasonably good at suggesting approaches to try, and not very inclined to identify slow runtime as a problem.  It tends to go for simple implementations until I ask about speed, which is certainly conventional wisdom for development.
> — [entrope on hackernews](https://news.ycombinator.com/item?id=50193722)

**Source threads**

- [hackernews](https://news.ycombinator.com/item?id=50193170) · 142 points · 31 comments

## Similar posts on daily.dev

- [GitHub - morishuz/delaunay32: Fast, parallel 2D Delaunay triangulation using exact integer predicates](https://daily.dev/posts/github---morishuz-delaunay32-fast-parallel-2d-delaunay-triangulation-using-exact-integer-predicate-oqviu9rdx) · Hacker News · 0 upvotes · 0 comments
- [A 3D Rasterizer For Embedded Devices](https://daily.dev/posts/a-3d-rasterizer-for-embedded-devices-zmdkm8rbk) · Hackaday · 0 upvotes · 0 comments
- [Turning 2D Projections Into 3D Pixel Art In Seconds](https://daily.dev/posts/turning-2d-projections-into-3d-pixel-art-in-seconds-bgla8go73) · 80 LEVEL · 1 upvotes · 0 comments
- [A Unique Performance Optimization for a 3D Geometry Language](https://daily.dev/posts/a-unique-performance-optimization-for-a-3d-geometry-language-ia3ak1s5n) · Lobsters · 0 upvotes · 0 comments
- [Optimizing CPU-side Rendering Code – Godot Engine](https://daily.dev/posts/optimizing-cpu-side-rendering-code-godot-engine-ty7sjfltq) · Godot · 15 upvotes · 0 comments

---

Tags: [#c++](https://daily.dev/tags/c++), [#webassembly](https://daily.dev/tags/webassembly)

[View this post on daily.dev](https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Faster than earcut: triangulating 3.7M map polygons in 489 ms","url":"https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef"},"datePublished":"2026-10-22T14:11:04.657Z","dateModified":"2026-10-22T16:39:09.513Z","description":"A map engine's polygon triangulator has been released as earstrip, an ISC-licensed C++ and WebAssembly library with the same API as earcut. It triangulates...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4dd6706baae4685b4e7f79da934662bc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4dd6706baae4685b4e7f79da934662bc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Hacker News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hacker News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/hn","url":"https://daily.dev/sources/hn"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c++,webassembly","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hacker News","item":"https://daily.dev/sources/hn"},{"@type":"ListItem","position":3,"name":"Faster than earcut: triangulating 3.7M map polygons in 489 ms"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/faster-than-earcut-triangulating-3-7m-map-polygons-in-489-ms-ml3fqleef#faq","mainEntity":[{"@type":"Question","name":"How much faster is earstrip than earcut.hpp for triangulating map polygons?","acceptedAnswer":{"@type":"Answer","text":"Earstrip triangulates 3.74 million real map polygons natively in C++ in 489 ms, compared to 557 ms for earcut.hpp, making it about 14% faster. In the browser via WebAssembly, earstrip is 1.4 to 2.1 times as fast as earcut.js depending on the calling pattern (loop inside the module versus per-polygon calls). On a polygon with 11,675 holes, earstrip takes 459 ms versus 2,892 ms for earcut.hpp. Comparing triangulation libraries for a map renderer? Track benchmarks like these on daily.dev before picking one."}},{"@type":"Question","name":"How do you handle polygon holes in ear clipping triangulation?","acceptedAnswer":{"@type":"Answer","text":"Each hole is cut open and stitched to the outer boundary with a bridge, an edge from a vertex of the hole to a vertex of the boundary walked once in each direction. The rightmost vertex of the hole casts a ray right; the first edge it hits determines a candidate bridge target, checked so the bridge triangle contains no other vertex, per David Eberly's write-up of ear clipping. Holes are bridged rightmost first so a hole further left can bridge into one already merged. Implementing geometry algorithms like hole-bridging? Keep reference breakdowns like this handy on daily.dev."}},{"@type":"Question","name":"What is a Delaunay triangulation and why is it useful?","acceptedAnswer":{"@type":"Answer","text":"A Delaunay triangulation is one where no point lies inside the circumscribed circle of any triangle's three corners, and among all triangulations of the same points it maximizes the smallest angle, avoiding needle-thin triangles. It's built incrementally by inserting vertices one at a time, splitting the triangle a point falls into, and flipping edges until the empty-circle rule holds again. 'Constrained' Delaunay forces the polygon's own edges to remain edges even where the circle rule would otherwise flip them. Choosing between Delaunay and ear-clipping triangulation for your renderer? Keep comparisons like this close on daily.dev."}}]}
```

