• Stars
    star
    321
  • Rank 130,752 (Top 3 %)
  • Language
    C#
  • License
    Other
  • Created over 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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

  • Vertex.cs
    • Basically a Vector2 point, but is aware of the polygon context it resides (neighbours, segments, edges, polygon, bisector, normal).
  • Segment.cs
    • Segment of two Vector2 point. Carries out basic geometry features (point distance, point containment, segment intersection).
  • Edge.cs
    • Edge of two Vertex in a polygon (a special Segment subclass). Likewise vertices, this model is also aware of the polygon context it resides (neighbours, segments, edges, polygon, perpendicular, normal).
  • Polygon.cs
    • The role player, it really embodies mostly every feature of this library. Basically a polygon made of vertices.
    • Can be created with point array, transforms, Source.Polygon components. Further polygons can be embedded into recursively. Vertices, edges, polygons can be enumerated (recursively).
    • Area, winding direction, centroid are being calculated. Also carries the basic geometry features (point containment, line-, segment-, polygon intersection and more).
    • Using library modules, it implements polygon offset (outline), union polygon (polygon clipping), basic mesh triangulation. It implements conversion to both Clipper and Triangle.NET, so you can implement further integration with those (awesome) libraries.

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.

  • Clipper

    • Polygon and line clipping and offsetting library (C++, C#, Delphi) by Angus Johnson. See standalone project repository Clipper for details.
  • Triangle.NET

    • Triangle.NET generates 2D (constrained) Delaunay triangulations and high-quality meshes of point sets or planar straight line graphs. It is a C# port by Christian Woltering of Jonathan Shewchuk's Triangle software. See standalone project repository Triangle.NET for details.

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

  • ClipperAddOns

    • Mainly Polygon extensions for easy conversion between eppz! Geometry and Clipper. It has a method to convert from generic Vector2[] array. Clipper works with integers. So conversion involves a scale up (and a scale down), thus you'll need to pass a scale value to Clipper. (for example eppz! Geometry internals use 10e+5f by default).
      • Polygon PolygonFromClipperPaths(Paths paths, float scale)
      • Polygon PolygonFromClipperPath(Path path, float scale)
      • Paths ClipperPaths(this Polygon this_, float scale)
      • Path ClipperPath(this Polygon this_, float scale)
      • Vector2[] PointsFromClipperPath(Path path, float scale)
  • TriangleNetAddOns

    • Bridges the gap between library Model.Polygon objects and Triangle.NET models (meshes, voronoi diagrams).
      • TriangleNet.Geometry.Polygon TriangleNetPolygon(this Polygon this_)
      • Rect Bounds(this TriangleNet.Voronoi.Legacy.SimpleVoronoi this_)
      • Paths ClipperPathsFromVoronoiRegions(List<TriangleNet.Voronoi.Legacy.VoronoiRegion> voronoiRegions, float scale = 1.0f)
      • Vector2 VectorFromPoint(TriangleNet.Geometry.Point point)
      • Vector2[] PointsFromVertices(ICollection<TriangleNet.Geometry.Point> vertices)
  • UnityEngineAddOns

    • Contains a single Model.Polygon (yet enormously useful) extension that triangulates the corresponding polygon, and hooks up the result into a UnityEngine.MeshFilter component. This is the core functionality embedded into Source.Mesh component (see example scene Polygon triangulation for more).
      • UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, string name = "")
      • UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, TriangulatorType triangulator, string name = "")
      • UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, Color color, TriangulatorType triangulator, string name = "")

License

Licensed under the MIT License.

More Repositories

1

iOS.Blog.SwiftUI_Search_Bar_in_Navigation_Bar

๐Ÿ” SwiftUI (1) search bar in the navigation bar.
Swift
174
star
2

Unity.Library.eppz.Lines

Lightweight OpenGL line rendering for Unity. Like Debug.DrawLine in Game view.
C#
127
star
3

Clipper

Polygon and line clipping and offsetting library (C++, C#, Delphi) by Angus Johnson. Forked from https://sourceforge.net/projects/polyclipping. I prepared a "Release" branch (containing C# source only) for submodule usage.
Pascal
105
star
4

Unity.Library.eppz

Unity everydayers.
C#
95
star
5

Unity.Blog.Unity_Android_plugin_tutorial

Unity native plugin (iOS / Android) example / boilerplate project.
C#
80
star
6

VSCode.Extension.eppz_Code

C# Visual Studio Code theme for Unity! Carefully designed colors with meanings.
C#
74
star
7

iOS.Blog.UILabel_Typography_Extensions

Set UILabel line height, letter spacing (and more). ๐Ÿ“
Swift
65
star
8

iOS.Library.eppz_kit

The collection of the usefuls. Objective-C everydayers.
Objective-C
49
star
9

iOS.Library.eppz_Xcode

An Xcode color scheme with meanings behind colors.
45
star
10

.NET.Library.TuyaKit

A library to control Tuya smart home devices via local TCP connection.
C#
44
star
11

iOS.Blog.SwiftUI_Pull_to_Refresh

โœณ๏ธ SwiftUI Pull to Refresh (for iOS 13 and iOS 14) condensed into a single modifier.
Swift
35
star
12

iOS.Package.Refreshable

โœณ๏ธ SwiftUI Pull to Refresh (for iOS 13 and iOS 14) package.
Swift
34
star
13

Unity.Labs.Unity_Player_Android

Decompiled Java sources of **Unity Player for Android** at the time of Unity 5.3.2.
Java
33
star
14

Unity.Blog.Override_App_Delegate

A maintainable way to extend / override app delegate in Unity iOS / OSX standalone player. (Much) more at http://eppz.eu/blog/override-app-delegate-unity-ios-osx-1/
Objective-C
31
star
15

iOS.Blog.UIView_from_Xib

Sample code for the article 5 approach to load UIView from Xib at eppz.eu/blog
Objective-C
30
star
16

iOS.Library.View_instantiator

Simplest way to load UIView from Xib.
Objective-C
27
star
17

iOS.Package.Withable

๐Ÿ“ Declarative UIKit in 10 lines of code.
Swift
27
star
18

iOS.Blog.Declarative_UIKit

A simple generic extension that can make building UI with UIKit more declarative.
Swift
25
star
19

Unity.Library.eppz.Cloud

๏ฃฟ iCloud Key-value store native iOS plugin for Unity. With callbacks on changes per value.
C#
21
star
20

Unity.Blog.My_Plugin

Unity native plugin (iOS / Android) Hello World! example project.
Objective-C
18
star
21

Unity.Library.eppz_easing

Easing algorithms with explanations / testbed.
C#
18
star
22

iOS.Library.eppz_reachability

A block-based extraction of Apple's Reachability sample.
Objective-C
16
star
23

Unity.Library.eppz.Utils

Small Unity helpers for the everyday.
C#
14
star
24

iOS.Package.KeyboardLayoutGuide

โŒจ๏ธ Backported keyboardLayoutGuide for iOS 13 and 14.
Swift
14
star
25

iOS.Blog.Custom_UITableViewCell_from_Xib

Custom UITableViewCell from Xib with ease.
Objective-C
10
star
26

Deprecated.Unity.Library.eppz

Unity everydayers, 2D geometry and more.
C#
10
star
27

Dot_Grid_A4

A blank dot grid PDF sheet (A4, 5mm).
7
star
28

Unity.Library.eppz.Rate

App Store rate mechanisms native iOS plugin for Unity.
C#
7
star
29

iOS.Library.eppz_swizzler

Basic swizzling wrapped up into an Objective-C interface.
Objective-C
7
star
30

iOS.Prototype.Neumorphism

An experiment to create photorealistic dynamic neumorph SwiftUI components rendered with SceneKit.
Swift
6
star
31

iOS.Blog.SpriteKit_drag

5 approach to implement SpriteKit drag (more at blog.eppz.eu)
Objective-C
6
star
32

macOS.Prototype.Ranger

Powerful PokerStars macOS HUD integrating both PokerTracker and SharkScope statistics.
Swift
5
star
33

Unity.Library.eppz.Meshes

Procedural runtime ring and circle mesh creator classes for Unity.
C#
5
star
34

JS.Labs.transform

CSS3 3D transformations playground.
JavaScript
5
star
35

Unity.Test.eppz

Unity Test project for https://github.com/eppz/Unity.Library.eppz to run Editor Tests on Travis CI.
Python
5
star
36

Unity.Library.eppz.DeepLink

๏ฃฟ Deep linking native iOS plugin for Unity. With deep link callbacks on app launch as well.
Objective-C
5
star
37

iOS.Blog.Codable

Codable Property Wrappers for the everyday.
Swift
4
star
38

iOS.Library.eppz_alert

Simplest UIAlertView wrapper ever.
Objective-C
4
star
39

iOS.Library.eppz_coreData

A simple drop-in Core Data sample class, actually a wrapper that manages a queue of any kind of objects without hassling with the Core Data boilerplate code.
Objective-C
4
star
40

Unity.Library.eppz.Extensions

String extensions for the everyday.
C#
4
star
41

Unity.Library.eppz.Persistence

๐Ÿ“ฆ Object serialization (Binary, JSON, Gzip) wrapped up for the everyday.
C#
4
star
42

Unity.Labs.OSX_Unity_Player_Headers

Dumped class headers from OSX Unity Player executable.
Objective-C
4
star
43

iOS.Library.eppz_settings

Drop-in NSUserDefaults settings manager for everyday use.
Objective-C
4
star
44

iOS.Blog.Understanding_SwiftUI_DSL

Recreating a SwiftUI hierarchy in "vanilla" Swift. Dissecting SwiftUI DSL step by step.
Swift
4
star
45

iOS.Library.eppz_model

A model layer for the everydays. Extreme simplicity (while fully customizable).
Objective-C
3
star
46

Unity.Library.eppz.Easing

Single file extract of the standalone project https://github.com/eppz/Unity.Library.eppz_easing.
C#
3
star
47

Unity.Blog.Understanding_IEnumerator

Sample code for http://eppz.eu/blog/understanding-ienumerator-in-unity-3d/
C#
3
star
48

macOS.Production.eppz_hide

A tiny little menulet app with the sole purpose of toggle showing hidden files.
Objective-C
2
star
49

Unity.UI

Mirror of official Unity UI system.
C#
2
star
50

macOS.Production.PDF_Links

Tiny tool help creating PDF links in Adobe Illustrator.
Swift
2
star
51

iOS.Prototype.Squishy

Squishy UI prototype.
Swift
2
star
52

iOS.Blog.Keyboard_Avoidance

โŒจ๏ธ Keyboard avoidance with a single line of code. Animate to text fields, swipe down keyboard dismissal for free.
Swift
2
star
53

iOS.Labs.Interactive_transitions

A dead simple wrapper around UIViewController transitions (also gesture driven interactivity).
Objective-C
2
star
54

SPICE

๐ŸŒ NASA's SPICE Toolkits for C.
C
2
star
55

JS.Library.eppz_js

Objective-Javascript. Classes, instance methods, class methods, inheritance, superclass implementation calls (with correct this referencing) and more.
JavaScript
2
star
56

iOS.Labs.physicsBody

SKPhysicsBody containment (covering) test category. Dead simple interface, runtimee implementation.
Objective-C
1
star
57

Unity.Library.eppz.Networking

Unity networking for the everyday.
C#
1
star
58

JS.Labs.filters

HTML5 <canvas> draft for visualizing signal filtering methods.
JavaScript
1
star