{"id":22396512,"url":"https://github.com/leondejong/js-sat","last_synced_at":"2026-02-08T00:01:47.750Z","repository":{"id":166996346,"uuid":"435605911","full_name":"leondejong/js-sat","owner":"leondejong","description":"Separating Axis Theorem","archived":false,"fork":false,"pushed_at":"2022-06-20T12:31:08.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T09:17:44.881Z","etag":null,"topics":["2d","axis","html","javascript","js","sat","separating","separating-axis-theorem","theorem"],"latest_commit_sha":null,"homepage":"https://leondejong.com/application/sat/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leondejong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2021-12-06T18:32:51.000Z","updated_at":"2025-06-26T20:15:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"36509d50-5bac-4d4d-840e-762ec5fa5876","html_url":"https://github.com/leondejong/js-sat","commit_stats":null,"previous_names":["leondejong/js-sat"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leondejong/js-sat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leondejong%2Fjs-sat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leondejong%2Fjs-sat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leondejong%2Fjs-sat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leondejong%2Fjs-sat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leondejong","download_url":"https://codeload.github.com/leondejong/js-sat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leondejong%2Fjs-sat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29213464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T23:58:20.073Z","status":"ssl_error","status_checked_at":"2026-02-07T23:58:07.729Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["2d","axis","html","javascript","js","sat","separating","separating-axis-theorem","theorem"],"created_at":"2024-12-05T06:08:21.237Z","updated_at":"2026-02-08T00:01:47.729Z","avatar_url":"https://github.com/leondejong.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Separating Axis Theorem\n\nThe SAT states that two convex objects do not overlap if there exists a line (called an axis) onto which the two objects' projections do not overlap.\n\nDisclaimer: obviously this is only a quick prototype/poc just for the fun of it.\n\n[Live version.](https://leondejong.com/application/sat)\n\n## SAT steps in general\n- Define or generate the vertex vectors of the tested polygons;\n- Calculate the edge vectors of the polygons, based on the vertices;\n- Calculate the normal vectors of the polygons (the vectors perpendicular to the edges);\n- Project the vertices of the polygons onto the normal vectors;\n- Select the min and max projection values of the tested polygons;\n- Compare the min and max projection values of the polygons to check if these overlap;\n- If the all projections on all normal vectors overlap, a separating axis can not be drawn between the polygons, and the objects collide;\n- Optionally calculate the MTV (minimum translation vector) to be able to compensate for the overlap.\n\n## Possible optimizations\n- Bail out as soon as one of the projections doesn't overlap (the `Array.prototype.every` function used here already takes care of that);\n- Regular polygons with an even amount of vertices only need half of their projections checked;\n- Use a quick precheck on the bounding box of each polygon to filter out cases that could not possibly overlap;\n- Concave polygons could potentially be tested by splitting these up into convex polygons first.\n\n[Collision detection.](https://github.com/leondejong/js-collision-detection)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleondejong%2Fjs-sat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleondejong%2Fjs-sat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleondejong%2Fjs-sat/lists"}