Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-212

3D IoU Axis-Aligned

Problem

Compute the intersection over union of two axis-aligned 3D boxes.

Boxes are [x1, y1, z1, x2, y2, z2] with continuous coordinates. Return intersection volume / union volume rounded to 4 decimal places, or 0.0 when the boxes do not overlap or a box is degenerate.

Test cases

case 1
in: [[0,0,0,2,2,2],[0,0,0,2,2,2]]
expected: 1
case 2
in: [[0,0,0,2,2,2],[3,3,3,5,5,5]]
expected: 0
case 3
in: [[0,0,0,2,2,2],[1,1,1,3,3,3]]
expected: 0.0667
case 4
in: [[0,0,0,4,4,4],[2,0,0,6,4,4]]
expected: 0.3333
Starter codePython
def iou_3d(box_a, box_b):
    # Your code here
    pass

4 test cases · run your code against them in the editor