{"id":15671585,"url":"https://github.com/winstxnhdw/2d-separating-axis-theorem","last_synced_at":"2026-01-24T03:09:16.379Z","repository":{"id":108152315,"uuid":"409092768","full_name":"winstxnhdw/2d-separating-axis-theorem","owner":"winstxnhdw","description":"C++ implementation of a 2D separating axis algorithm.","archived":false,"fork":false,"pushed_at":"2024-04-23T15:56:45.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T23:41:52.411Z","etag":null,"topics":["collision-detection","hyperplane-separation-theorem","separating-axis-theorem","two-dimensional"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winstxnhdw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-09-22T06:43:01.000Z","updated_at":"2024-04-23T15:56:48.000Z","dependencies_parsed_at":"2024-10-03T15:03:48.701Z","dependency_job_id":"966dc9b7-1a6f-47a8-9ce9-9173ff08f0bd","html_url":"https://github.com/winstxnhdw/2d-separating-axis-theorem","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/winstxnhdw%2F2d-separating-axis-theorem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2F2d-separating-axis-theorem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2F2d-separating-axis-theorem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2F2d-separating-axis-theorem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winstxnhdw","download_url":"https://codeload.github.com/winstxnhdw/2d-separating-axis-theorem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862768,"owners_count":21173877,"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":["collision-detection","hyperplane-separation-theorem","separating-axis-theorem","two-dimensional"],"created_at":"2024-10-03T15:03:42.578Z","updated_at":"2026-01-24T03:09:11.355Z","avatar_url":"https://github.com/winstxnhdw.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 2d-separating-axis-theorem\n\nThis repository contains a simple C++ implementation of a 2D separating axis algorithm. The algorithm does not compute the [Minimum Translation Vector (MTV)](https://dyn4j.org/2010/01/sat/#sat-mtv) as it is not within my use case. For more information, read [here](https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169). \n\n\u003e **Warning**: The comparing polygons must have an equal number of vertices. This does not necessarily have to be the case but I didn't have time to write that feature.\n\n```yaml\n:param bounds_a:            (vector\u003cx, y\u003e) vertices of polygon A\n:param bounds_b:            (vector\u003cx, y\u003e) vertices of polygon B\n\n:return isIntersecting:     (bool) true if the two polygons are intersecting\n```\n\n## Test\n\n```bash\ng++ main.cpp\n./a.out\n```\n\n## Example\n\nThe following snippet is an example used in actual production.\n\n```c++\nfor (size_t j = 0; j \u003c static_obstacles_set.size(); j++) {\n    const std::vector\u003cVector2\u003e static_obstacle = {\n        static_obstacles_set[j].points[0],\n        static_obstacles_set[j].points[1],\n        static_obstacles_set[j].points[2],\n        static_obstacles_set[j].points[3]\n    };\n\n    const bool isIntersecting = separating_axis_intersect(vehicle_bounds, static_obstacle);\n\n    if (intersects) {\n        path.is_blocked = true;\n        path.is_static_obstacle = true;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinstxnhdw%2F2d-separating-axis-theorem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinstxnhdw%2F2d-separating-axis-theorem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinstxnhdw%2F2d-separating-axis-theorem/lists"}