All files / core/domain/utils/geometry axis.js

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

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                  8x              
/**
 * 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, c2) {
  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 }
  ];
}