Polygon Triangulation Module

November 9, 2019 EDIT: I found a horrible edge case regarding nearby integers a while back and haven’t and won’t fix them. Don’t use this module.

I wrote a module that fills any simple polygon with right triangles. Simple means:

  1. No holes
  2. No intersecting edges
  3. No vertices at the same position

It has an upper bound of O(n3). A faster implementation already exists, but the file is no longer available.

Extra Information

I attempted this challenge because I needed to fill a hexagon for a project. Unbeknownst to me, polygon triangulation is a popular problem, and the algorithm I devised is actually a common algorithm called ear clipping. I wrote the first version entirely myself, so after discovering this problem online, I replaced some of my math with others’ faster math. The final version is about half and half. Much quicker algorithms exist than ear clipping, but I’ll save that for someone else. :wink:

Files

If you want to play with the polygon editor seen in the GIF, download the place file. Otherwise, grab the module.

Module: Polygon Triangulator - Roblox
Polygon Editor: file removed because the script is broken

I have yet to find any edge-case polygons that triangulate incorrectly. If you do, please let me know.

21 Likes

@AstroCode you forgot to put the module on sale

2 Likes

Any possible chance you could convert this over to a plugin? Would greatly appreciate it if so.

Whoops, thanks for letting me know. “For sale” got changed to “Allow copying” which confused me.

What uses do you propose this plugin have? I can’t think of any atm.

1 Like

Using modules isn’t something the average builder is familiar with. Difficulty varies from person to person, however I feel as if it wouldn’t hurt to be converted over.

FYI just fixed a bug that caused the ImageLabels to not be returned.