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 | 6x 8x | import { Point, RectangleCorners } from "./interfaces";
/**
* Compute the four axis between corners of rectangle A and corners of
* rectangle B. This is needed later to check an eventual collision.
*
* @param {array} An array of rectangle A's four corners (x, y).
* @param {array} An array of rectangle B's four corners (x, y).
* @return {array} An array of four axis defined by their coordinates (x,y).
*/
export default function axis(
c1: RectangleCorners,
c2: RectangleCorners
): [Point, Point, Point, Point] {
return [
{ x: c1[1].x - c1[0].x, y: c1[1].y - c1[0].y },
{ x: c1[1].x - c1[3].x, y: c1[1].y - c1[3].y },
{ x: c2[0].x - c2[2].x, y: c2[0].y - c2[2].y },
{ x: c2[0].x - c2[1].x, y: c2[0].y - c2[1].y }
];
}
|