PolygonUtils - a module for all your polygon needs

PolygonUtils is a module that contains various functions that have to do with polygons whether it includes detecting whether a point is within a polygon or even getting the area of a polygon. All of the functions it includes are listed here.

  • Detecting whether a point is in a polygon or not
  • Detecting whether a point is on the side of a polygon or not
  • Detecting whether two lines collide
  • Detecting if a line passes through a polygon
  • Detecting if a part is fully inside a polygon
  • Aproximating the area of a polygon
  • Calculating the centroid of a polygon

A “polygon” is defined as a table of positions in order. (The y axis of a vertex does not matter as it only takes the x and z into account.)

local polygon = {part1.Position, part2.Position, part3.Position}

Here are some examples of it being used.



16 Likes

I was just about to make my own module just like this! This module is going to save me a load of time! Thanks a million for open sourcing this.

3 Likes

No problem! I made this because I wanted to be able to create a system where you could define a property using stakes and build within it. Nice to see someone else has a use for it! Feel free to reach out to me if you find any problems with the module.

2 Likes