Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 8x 8x 8x 32x 8x | import axis from "./axis";
import axisCollision from "./axisCollision";
/**
* Check whether two rectangles collide on each one of their four axis. If
* all axis collide, then the two rectangles do collide on the plane.
*
* @param {array} Rectangle A's corners.
* @param {array} Rectangle B's corners.
* @return {boolean} True if the rectangles collide.
*/
export default function collision(c1, c2) {
const axs = axis(c1, c2);
let col = true;
for (let i = 0; i < 4; i++) {
col = col && axisCollision(axs[i], c1, c2);
}
return col;
}
|