Other

项目介绍

Geri-Borbas/Unity.Library.eppz.Geometry 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 Other 许可证,目前获得 335 个 Star、58 次 Fork。

仓库全名
Geri-Borbas/Unity.Library.eppz.Geometry
开源许可证
Other
Star 数
335
Fork 数
58
未关闭 Issue
5

README 摘要

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,…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Unity.Library.eppz.Geometry 用什么语言开发?

主要使用 C# 编写,采用 Other 许可证,目前有 335 个 Star。

Unity.Library.eppz.Geometry 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 Unity.Library.eppz.Geometry 的源码?

可以直接克隆仓库:git clone https://github.com/Geri-Borbas/Unity.Library.eppz.Geometry.git,默认分支为 master;安装与运行步骤见仓库 README。

Unity.Library.eppz.Geometry 最近还在维护吗?

仓库最近一次更新为 2018年1月26日,当前有 5 个未关闭 Issue;Star 数为 335,可作为社区活跃度的参考。

关于

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.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

语言占比

C#
ShaderLab

Release

贡献者

README

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.

评论

暂无评论