{"id":40882467,"url":"https://github.com/bertt/triangulator","last_synced_at":"2026-01-22T01:16:45.301Z","repository":{"id":65313945,"uuid":"270235276","full_name":"bertt/triangulator","owner":"bertt","description":".NET Standard 2.0 Library for triangulating 3D geometries","archived":false,"fork":false,"pushed_at":"2025-12-16T11:14:09.000Z","size":542,"stargazers_count":15,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-20T00:33:44.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bertt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-06-07T07:58:25.000Z","updated_at":"2025-12-16T15:38:41.000Z","dependencies_parsed_at":"2024-08-08T09:06:02.843Z","dependency_job_id":"3689c35a-3e2f-46eb-aaed-60d2380978c9","html_url":"https://github.com/bertt/triangulator","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"bc3b12cdfadd525b284b58baaf294629a4050e9c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bertt/triangulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertt%2Ftriangulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertt%2Ftriangulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertt%2Ftriangulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertt%2Ftriangulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bertt","download_url":"https://codeload.github.com/bertt/triangulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertt%2Ftriangulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28648639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-22T01:16:44.634Z","updated_at":"2026-01-22T01:16:45.289Z","avatar_url":"https://github.com/bertt.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Triangulator\n\n.NET Standard 2.0 library for triangulating 2D/3D WKB geometries (PolyhedralSurface/MultiPolygon/Polygon/Multiline/Line) using Earcut algorithm.\n\n## NuGet\n\nhttps://www.nuget.org/packages/bertt.triangulator/\n\n## Sample code\n\n```\nvar buildingWkb = File.ReadAllBytes(@\"testdata/building.wkb\");\nvar wkbTriangulated = Triangulator.Triangulate(buildingWkb);\nvar triangulatedGeometry = (PolyhedralSurface)Geometry.Deserialize\u003cWkbSerializer\u003e(wkbTriangulated);\nAssert.IsTrue(triangulatedGeometry.Geometries.Count == 22);\n```\n\n## Sample result triangulating polyhedralsurface:\n\nFrom: \n\n```\nPOLYHEDRALSURFACE Z (((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1)))\n```\n\nTo:\n\n```\nPOLYHEDRALSURFACE Z (((0 0 0,0 1 0,1 0 0,0 0 0)),((1 1 0,1 0 0,0 1 0,1 1 0)),((0 0 1,0 0 0,0 1 0,0 0 1)),((0 1 0,0 1 1,0 0 1,0 1 0)),((0 0 1,0 0 0,1 0 0,0 0 1)),((1 0 0,1 0 1,0 0 1,1 0 0)),((1 1 1,1 0 1,0 1 1,1 1 1)),((0 0 1,0 1 1,1 0 1,0 0 1)),((1 1 0,1 1 1,1 0 1,1 1 0)),((1 0 1,1 0 0,1 1 0,1 0 1)),((1 1 1,1 1 0,0 1 1,1 1 1)),((0 1 0,0 1 1,1 1 0,0 1 0)))\n```\n\nSample result triangulation with interior rings:\n\n\u003cimg src=\"holes.png\" width=\"300\" /\u003e\n\nSample with multiple interior rings:\n\n![image](https://github.com/user-attachments/assets/c6b71969-f2bc-4e5c-b4d1-c8abc1a147c5)\n\n## Remarks\n\n- Input wkb must be of type PolyhedralSurface/MultiPolygon/Polygon/Line/Multiline, otherwise an error will occur;\n- Triangulated geometry is returned as WKB (as PolyhedralSurface/MultiPolygon);\n\n## Polygons Method \n\n3D Triangulation is performed in 2D mode, by projecting each input polygon\nto yz, zx or xy plane. The plane to project to is determined by the normal vector of the \ninput polygon.\n\nPseudo code for calculating plane to project to (nb: using absolute normals here): \n\n```\nyz: when (normal(x) \u003e normal(y)) and (normal(x) \u003e normal(z))\nzx: else when (normal(y) \u003e normal(z))\nxy: all other cases\n```\n\nFor triangulation the fast Earcut method is \nused. After triangulation the resulting triangles are 'unflattened' to get the \n3D triangles. \n\nAfter that, each triangle is checked to have the same direction as the original polygon by calculating\nthe dot product between the normal of the polygon and the normal of the triangle. If the dot \nproduct is negative, then the two vectors point in opposite directions and the triangle will be \ninverted.\n\n## lines Method \n\nTriangles of (multi)lines can be calculate using the Triangulate method using the following parameters:\n\n - (Multi)LineString lineString: line geometry\n\n - float radius = 1\n \n - int radialSegments = 8\n\n Sample code:\t\n\n ```\nvar wkt = \"LINESTRING(-10 0 0,0 0 0,0 10 0)\";\nvar line = (LineString)Geometry.Deserialize\u003cWktSerializer\u003e(wkt);\nvar triangles = Triangulator.Triangulate(line,2);\n```\n\n## Benchmark\n\ntodo\n\n## Unit Testing\n\nIn the unit test there is an conversion method from triangles to glTF 2.0 using SharpGLTF (https://github.com/vpenades/SharpGLTF)\nfor visual inspections.\n\n## Dependencies\n\nwkx-sharp - https://github.com/cschwarz/wkx-sharp for handling geometries\n\n## History\n\n2025-12-16: release 1.7.0: to .NET Standard 2.0 library \n\n2025-03-05: release 1.6.0: remove THREE dependency for lines + to .NET 6.0\n\n2024-09-03: release 1.5.2: fix interior rings triangulation\n\n2024-08-08: release 1.5.1: add support for lines without z (assuming z=0)\n\n2024-07-30: release 1.5.0: to .NET 8 + use LineCurve instead of CatmullRomCurve (better performance + more accurate)\n\n2024-02-20: release 1.4.3: fix lines of 2 points\n\n2024-02-20: release 1.4.2: add multi-line support\n\n2024-02-14: release 1.4.1: make tubularSegments and radialSegments optional\n\n2024-02-14: release 1.4.0: add support for lines\n\n2024-02-07: release 1.3.1: normals algorithm fix for higher precision\n\n2024-02-07: release 1.3.0: add support for interior rings + polygons\n\n2023-09-26: release 1.2.3: fix normal close to 0\n\n2023-09-22: release 1.2.2: fix normals calculation\n\n2023-08-30: release 1.2.1: add support for Geometry type as input (in addition of WKB)\n\n2023-08-30: release 1.2: add support for MultiPolygon\n\n2020-09-01: release 1.1: to NET 6\n\n2020-06-10: release 1.0.3\n\n2020-06-09: release 1.0.2\n\n2020-06-08: release 1.0.1\n\n2020-06-07: release 1.0.0 Initial release\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertt%2Ftriangulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbertt%2Ftriangulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertt%2Ftriangulator/lists"}