{"id":16410254,"url":"https://github.com/danasilver/polygon","last_synced_at":"2025-10-10T04:36:43.143Z","repository":{"id":18024947,"uuid":"21057875","full_name":"danasilver/polygon","owner":"danasilver","description":"A standalone library for working with polygons.","archived":false,"fork":false,"pushed_at":"2014-06-26T04:34:07.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T02:31:16.560Z","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/danasilver.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":"2014-06-21T01:59:28.000Z","updated_at":"2014-06-26T04:36:28.000Z","dependencies_parsed_at":"2022-08-26T10:10:47.082Z","dependency_job_id":null,"html_url":"https://github.com/danasilver/polygon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danasilver/polygon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fpolygon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fpolygon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fpolygon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fpolygon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danasilver","download_url":"https://codeload.github.com/danasilver/polygon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fpolygon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002667,"owners_count":26083442,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-10-11T06:23:38.688Z","updated_at":"2025-10-10T04:36:43.127Z","avatar_url":"https://github.com/danasilver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## polygon\n\nA standalone library for working with polygons.\n\nRuntimes are given in terms of the number of points.\n\n### Testing\n\nInstall the dev dependencies:\n\n```sh\n$ npm install\n```\n\nAnd run the tests:\n\n```sh\n$ npm test\n```\n\n### Construction\n\n```js\nvar p = polygon();\n```\n\n### Points\n\nCall `points` once or multiple times to add points.\n\n```js\np.points([[0, 0], [1, 0], [1, 1], [1, 2], [0, 1]]);\n```\n\nCall `points` with no arguments to get the points.\n\n```js\np.points();\n//=\u003e [[0, 0], [1, 0], [1, 1], [1, 2], [0, 1]]\n```\n\n### Clear\n\n```js\np.clear();\n```\n\n### Area\n\nCalculated as the sum of the determinants of consecutive vertices as described\non [Wolfram MathWorld](http://mathworld.wolfram.com/PolygonArea.html).\n\nArea is signed and defined for a convex polygon to be positive if the points are\narranged in counterclockwise order and negative if they are in clockwise order.\n\nO(n)\n\n```js\np.area();\n//=\u003e 1.5\n```\n\n### Perimeter\n\nCalculated as the sum of the\n[Euclidean distances](http://en.wikipedia.org/wiki/Euclidean_distance) between\nconsecutive vertices.\n\nO(n)\n\n```js\np.perimeter();\n//=\u003e 5.414213562373095\n```\n\n### Centroid\n\n![Cx](http://upload.wikimedia.org/math/e/e/1/ee14cbb2b170c4bb435f1d84e78f6d66.png)\n\n![Cy](http://upload.wikimedia.org/math/a/4/c/a4cee81a1d18e4d067f66d4d40a8a1fe.png)\n\n[http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon](http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon)\n\nO(n)\n\n```js\np.centroid();\n//=\u003e [0.5555555555555556, 0.7777777777777777]\n```\n\n### Point in Polygon\n\nSee http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html.\n\n### Convex\n\n### Simple\n\n### Intersecting\n\n### Triangulation\n\n### Minimum Weight Triangulation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanasilver%2Fpolygon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanasilver%2Fpolygon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanasilver%2Fpolygon/lists"}