Skip to content

Ginxss/gjk-epa-2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gjk-epa-2d

GJK (Gilbert–Johnson–Keerthi) and EPA (Expanding Polytope Algorithm) in 2D


Just collision detection:

#include "collision.hpp"

if (intersect(shape1, shape2)) {
    // shape1 and shape2 intersect
}

You can provide a penetration vector to be filled out as well:

#include "collision.hpp"

Vector2D penetration;
if (intersect(shape1, shape2, &penetration)) {
    // Move shape1 by -penetration or shape2 by penetration to avoid collision
}

Of course, the penetration vector needs to be a Vector2D and the tested shapes need to be derivatives of the class Shape.

New derivatives of Shape can easily be added, they just need to provide a support function.

About

Collision detection and avoidance with GJK and EPA in 2D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages