2 """
3 a, b ... coordinates in packing format
4
5 so its [x, y, w, h] or [x, y, z, w, h, d]
6 """
7 from exceptions import ValueError
8
9 dims = len(a)/2
10 assert(len(a) == len(b))
11
12 length = 0.0
13 if dims == 2:
14 length += abs((a[0]+a[2]/2) - (b[0]+b[2]/2))
15 length += abs((a[1]+a[3]/2) - (b[1]+b[3]/2))
16 elif dims == 3:
17 length += abs((a[0]+a[3]/2) - (b[0]+b[3]/2))
18 length += abs((a[1]+a[4]/2) - (b[1]+b[4]/2))
19 length += z_weight*abs((a[2]+a[5]/2) - (b[2]+b[5]/2))
20 else:
21 raise ValueError("wrong packing format")
22
23 return length
24