blaze-2d
Version:
A fast and simple WebGL 2 2D game engine written in TypeScript
29 lines (28 loc) • 1.16 kB
TypeScript
import { vec2 } from "gl-matrix";
import Collider from "./collider/collider";
/**
* The collision normal and penetration depth computed by the EPA algorithm.
*
* @field **normal** The collision normal
* @field **depth** The penetration depth of the collision
*/
interface EPAResult {
normal: vec2;
depth: number;
}
/**
* Performs EPA collision response algorithm between 2 colliders.
*
* For a detailed explanation on how this algorithm works:
* - @see [dyn4j EPA Post](https://dyn4j.org/2010/05/epa-expanding-polytope-algorithm/)
* - @see [hamaluik EPA Post](https://blog.hamaluik.ca/posts/building-a-collision-engine-part-2-2d-penetration-vectors/)
* - @see [WinterDev EPA Explanation](https://blog.winter.dev/2020/epa-algorithm/)
* - @see [EPA Visualisation](https://winter.dev/lilapps/gjk/index.html)
*
* @param polytope The final simplex from the GJK algorithm between a and b.
* @param a The first collider
* @param c The second collider
* @returns A {@link EPAResult} object containing the results of the EPA algorithm
*/
export default function EPA(polytope: vec2[], a: Collider, b: Collider): EPAResult;
export {};