{"id":25065837,"url":"https://github.com/dubniczky/convex-hull","last_synced_at":"2025-03-31T13:28:26.016Z","repository":{"id":160045560,"uuid":"520952824","full_name":"dubniczky/Convex-Hull","owner":"dubniczky","description":"Optimizing a convex hull using trigonometric elimination on a web environment","archived":false,"fork":false,"pushed_at":"2022-08-03T16:37:12.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T19:49:26.147Z","etag":null,"topics":["algorithm","javascript","optimization","p5js","web"],"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/dubniczky.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}},"created_at":"2022-08-03T16:21:30.000Z","updated_at":"2022-08-03T16:33:50.000Z","dependencies_parsed_at":"2023-07-05T19:17:47.295Z","dependency_job_id":null,"html_url":"https://github.com/dubniczky/Convex-Hull","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FConvex-Hull","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FConvex-Hull/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FConvex-Hull/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FConvex-Hull/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dubniczky","download_url":"https://codeload.github.com/dubniczky/Convex-Hull/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246473357,"owners_count":20783258,"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":["algorithm","javascript","optimization","p5js","web"],"created_at":"2025-02-06T19:45:10.723Z","updated_at":"2025-03-31T13:28:26.009Z","avatar_url":"https://github.com/dubniczky.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/dubniczky"],"categories":[],"sub_categories":[],"readme":"# Trigonometric Convex Hull\n\nOptimizing a convex hull using trigonometric elimination.\n\n## Support ❤️\n\nIf you find the project useful, please consider supporting, or contributing.\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/dubniczky)\n\n## Live Demo\n\nhttps://dubniczky.github.io/Convex-Hull/\n\n## Algorithm details\n\n1. Calculate center point from average positions.\n2. Sort points based on distance from center.\n3. Eliminate center points using triangle intersection.\n4. Sort remaining points based on theta angle from center.\n5. Connect remaining points in sequence.\n\n## Triangle intersection code sample\n\n```javascript\nlet edges = []\nfor (let i = points.length - 1; i \u003e= 0; i--) {\n    let intersect = false\n    for (let j = 0; !intersect \u0026\u0026 j \u003c points.length - 1; j++) {\n        if (j == i) {\n            continue\n        }\n        for (let k = j + 1; !intersect \u0026\u0026 k \u003c points.length; k++) {\n            if (k == i) {\n                continue\n            }\n\n            let a = points[i]\n            let b = points[j]\n            let c = points[k]\n            let d = center\n\n            let d1 = (a.pos.x - c.pos.x) * (b.pos.y - c.pos.y) - (b.pos.x - c.pos.x) * (a.pos.y - c.pos.y)\n            let d2 = (a.pos.x - d.pos.x) * (b.pos.y - d.pos.y) - (b.pos.x - d.pos.x) * (a.pos.y - d.pos.y)\n            let d3 = (a.pos.x - d.pos.x) * (c.pos.y - d.pos.y) - (c.pos.x - d.pos.x) * (a.pos.y - d.pos.y)\n\n            let neg = (d1 \u003c 0) || (d2 \u003c 0) || (d3 \u003c 0)\n            let pos = (d1 \u003e 0) || (d2 \u003e 0) || (d3 \u003e 0)\n\n            if (!(neg \u0026\u0026 pos)) {\n                intersect = true\n            }\n        }\n    }\n    if (!intersect) {\n        edges.push(i)\n    }\n}\n```\n\n\n## Usage\n\nRun the `./deploy.sh` script.\n\nHost `./public` folder on a static file server or open `./public/index.html` locally in your browser.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubniczky%2Fconvex-hull","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubniczky%2Fconvex-hull","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubniczky%2Fconvex-hull/lists"}