{"id":16126823,"url":"https://github.com/mikolalysenko/split-polygon","last_synced_at":"2025-03-16T09:32:06.846Z","repository":{"id":11107400,"uuid":"13462342","full_name":"mikolalysenko/split-polygon","owner":"mikolalysenko","description":"Splits a convex polygon by a plane","archived":false,"fork":false,"pushed_at":"2014-06-19T15:20:20.000Z","size":144,"stargazers_count":16,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T06:12:04.514Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mikolalysenko.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}},"created_at":"2013-10-10T04:54:12.000Z","updated_at":"2023-02-06T07:05:35.000Z","dependencies_parsed_at":"2022-09-10T11:01:15.328Z","dependency_job_id":null,"html_url":"https://github.com/mikolalysenko/split-polygon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Fsplit-polygon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Fsplit-polygon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Fsplit-polygon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Fsplit-polygon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikolalysenko","download_url":"https://codeload.github.com/mikolalysenko/split-polygon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809865,"owners_count":20351403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-09T21:40:31.991Z","updated_at":"2025-03-16T09:32:06.551Z","avatar_url":"https://github.com/mikolalysenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"split-polygon\n=============\nSplits a *convex* polygon by a plane into two parts (or optionally clips the polygon against a single plane) using the Sutherland-Hodgman algorithm.  Works in arbitrary dimensions, both in the server and the browser\n\n## Install\n\n    npm install split-polygon\n\n## Example\n\n```javascript\nvar splitPolygon = require(\"split-polygon\")\n\nvar poly = [[1,2], [3,4], [0,0]]\n\nvar parts = splitPolygon(poly, [0, 1, 3])\n\nconsole.log(parts.positive)\nconsole.log(parts.negative)\n```\n\n## API\n\n```javascript\nvar splitPolygon = require(\"split-polygon\")\n```\n\n### `splitPolygon(poly, plane)`\nSplits the *convex* polygon `poly` against plane into two parts, one above the plane and the other below it.  The equation for the plane is determined by:\n\n```javascript\nfunction planeDistance(x) {\n  return plane[0] * x[0] + plane[1] * x[1] + ... + plane[n-1] * x[n-1] + plane[n]\n}\n```\n\nPoints above the plane are those where `planeDistance(x) \u003e= 0` and below are those with `planeDistance(x) \u003c= 0`\n\n* `poly` is a *convex* polygon\n* `plane` is the plane\n\n**Returns** An object with two properties:\n\n* `positive` is the portion of the polygon above the plane\n* `negative` is the portion of the polygon below the plane\n\n### `splitPolygon.positive(poly, plane)`\nSame result as splitPolygon, except only returns the positive part.  This saves a bit of memory if you only need one side.\n\n### `splitPolygon.negative(poly, plane)`\nDitto, except returns only the negative part.\n\n## Credits\n(c) 2013 Mikola Lysenko. MIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikolalysenko%2Fsplit-polygon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikolalysenko%2Fsplit-polygon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikolalysenko%2Fsplit-polygon/lists"}