Geri-Borbas / Unity.Library.eppz.Geometry

2D Geometry for Unity. Suited for everyday polygon hassle. Polygon clipping, polygon winding direction, polygon area, polygon centroid, centroid of multiple polygons, line intersection, point-line distance, segment intersection, polygon-point containment, polygon triangulation, polygon Voronoi diagram, polygon offset, polygon outline, polygon buffer, polygon union, polygon substraction, polygon boolean operations, and more. It is a polygon fest.
Other
321 stars 58 forks source link
accuracy buffering centroid clipper clipping distance-calculation geometry intersect intersection intersection-point polygon scene segment triangulation unity voronoi voronoi-diagram

eppz! Geometry

part of Unity.Library.eppz

📐 2D geometry for Unity. Suited for everyday polygon hassle.

Polygon clipping, polygon winding direction, polygon area, polygon centroid, centroid of multiple polygons, line intersection, point-line distance, segment intersection, polygon-point containment, polygon triangulation, polygon Voronoi diagram, polygon offset, polygon outline, polygon buffer, polygon union, polygon substraction, polygon boolean operations, and more.

Unity.Library.eppz.Geometry.Model.Poygon.Mesh.Triangulation

The library is being used in production. However, it comes with the disclaimed liability and warranty of MIT License.

Examples

If you prefer to read example code immediately, you can find example scenes in Scenes folder.

Model classes

Geometry.cs

Most of the basic 2D geometry algorithm collection is implemented in this static base class. You can (mostly) use them with Unity Vector2 types directly, so (almost entirely) without the model classes introduced above.

Modules

For clipping, offsetting, triangulating the library use these brilliant third party C# libraries below.

Naming

The library uses namespaces heavily. I like to name things as they are. An edge in this library called Edge, a polygon is called Polygon. If it is a polygon model, it resides the Model namespace (EPPZ.Geometry.Model actually). Whether it is a source component for polygon, it resides in the Source namespace. It becomes nicely readable, as you declare polygons like Model.Polygon, or reference polygon sources as Source.Polygon.

In addition, every class is namespaced in the folder it resides. If you look at a folder name, you can tell that classes are namespaced to the same as the folder name.

Add-ons

License

Licensed under the MIT License.