MCPcopy Create free account
hub / github.com/Sin3DM/Sin3DM / normalize_aabb

Function normalize_aabb

data/utils.py:19–44  ·  view source on GitHub ↗
(v, reso, enlarge_scale=1.03, mult=8)

Source from the content-addressed store, hash-verified

17
18
19def normalize_aabb(v, reso, enlarge_scale=1.03, mult=8):
20 aabb_min = np.min(v, axis=0)
21 aabb_max = np.max(v, axis=0)
22 center = (aabb_max + aabb_min) / 2
23 bbox_size = (aabb_max - aabb_min).max() * enlarge_scale
24 print("center:", center)
25 print("bbox size", bbox_size)
26
27 translation = -center
28 scale = 1.0 / bbox_size * 2
29 # v = (v + translation) * scale
30 # v = (v - center) / bbox_size * 2
31 aabb_min = (aabb_min * enlarge_scale - center) / bbox_size * 2
32 aabb_max = (aabb_max * enlarge_scale - center) / bbox_size * 2
33 aabb = np.concatenate([aabb_min, aabb_max], axis=0)
34 print("v max:", v.max(axis=0), "v min:", v.min(axis=0))
35 print("aabb:", aabb)
36
37 aabb_size = aabb_max - aabb_min
38 fm_size = (reso * aabb_size / aabb_size.max()).astype(np.int32)
39 # round to multiple of 8
40 fm_size = (fm_size + mult - 1) // mult * mult
41 aabb_max = fm_size / fm_size.max()
42 aabb = np.concatenate([-aabb_max, aabb_max], axis=0)
43 print("aabb:", aabb)
44 return aabb, translation, scale

Callers 2

normalizeMethod · 0.90
normalizeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected