All files / packages/tools/src/utilities/math/aabb intersectAABB.ts

100% Statements 1/1
100% Branches 4/4
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 18 19 20                        1x              
import { Types } from '@cornerstonejs/core';
 
/**
 * Check if two axis-aligned bounding boxes intersect
 * @param aabb1 - First AABB
 * @param aabb2 - Second AABB
 * @returns True if they intersect or false otherwise
 */
export default function intersectAABB(
  aabb1: Types.AABB2,
  aabb2: Types.AABB2
): boolean {
  return (
    aabb1.minX <= aabb2.maxX &&
    aabb1.maxX >= aabb2.minX &&
    aabb1.minY <= aabb2.maxY &&
    aabb1.maxY >= aabb2.minY
  );
}