question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Split triangulation differently to produce more regular triangles

See original GitHub issue

I’m trying to do some transitions on the topojson/world-atlas 110m map and finding that some of the more complicated geographies break a lot of the time when calling flubber.combine.

I’ve got a reproducible block up here [gist].

If you add e.g. the United States back in (by no longer filtering out id=840 in line 46) it’ll break, saying Uncaught RangeError: Can't collapse topology into 10 pieces.. Changing maxSegmentLength can make things better or worse, causing more or fewer countries to break (but I’ve yet to find a value that works for all of them).

Also, thanks for the awesome library! I’ve been eagerly watching your bl.ocks for a while and wanting to give these transitions a try, and this makes it so easy to do.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
veltmancommented, Jun 12, 2017

Thanks for the detailed post! This is actually on my todo list - basically if you have a multishape with n shapes, your single shape currently needs at least n+2 vertices in order to get triangulated into enough pieces. So in your case, using the default maxSegmentLength for those circles looks like it gives you a nonagon, so any feature with 8 or more parts would fail.

This fix has been delayed a little because rather than add colinear points on the original shape, which can result in weird slivers, I think the right approach is to still triangulate normally first, but then to split those triangles in half if needed, and that’s a bit more involved to implement. But hopefully I should have it in there in the next few days.

In the meantime, as you mention you could decrease maxSegmentLength, or you could limit the shapes to the eight largest polygons, or simplify the geometry until none of the features have that many.

0reactions
veltmancommented, Jun 15, 2017

Thought about this a bit more and I think the way to go is probably to split any triangle that’s more than x% of the total area from the midpoint of its longest side to the opposite vertex before the merge step. That ought to result in fewer sliver triangles that span the whole width/height of the shape, and it would never result in more than a handful of extra ops.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polygon Triangulation - UCSB Computer Science
Partition polygon P into non-overlapping triangles using diagonals only. • Is this always possible for any simple polygon? If not, which polygons are....
Read more >
Triangles and Simplices - The Geometry Junkyard
I am particularly interested in triangulation by which I mean partitioning regions into triangles, tetrahedra, or higher dimensional simplices, for various ...
Read more >
Chapter 3. Triangulation Hierarchies
Splitting this type of triangle on all edges partitions high-frequency regions which may then be further refined. This refinement technique strives primarily to ......
Read more >
Point-set triangulation
Sometimes it is desirable to have a triangulation with special properties, e.g., in which all triangles have large angles (long and narrow ("splinter") ......
Read more >
Decimation
This is because for every cube intersecting the surface, marching cubes must produce a triangulation. These triangulations consist of 1-4 triangles, and thus ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found