MCPcopy Create free account
hub / github.com/OpenMeshLab/MeshXL / shift_scale_points

Function shift_scale_points

utils/pc_util.py:38–66  ·  view source on GitHub ↗

pred_xyz: B x N x 3 src_range: [[B x 3], [B x 3]] - min and max XYZ coords dst_range: [[B x 3], [B x 3]] - min and max XYZ coords

(pred_xyz, src_range, dst_range=None)

Source from the content-addressed store, hash-verified

36# Simple Point manipulations
37# ----------------------------------------
38def shift_scale_points(pred_xyz, src_range, dst_range=None):
39 """
40 pred_xyz: B x N x 3
41 src_range: [[B x 3], [B x 3]] - min and max XYZ coords
42 dst_range: [[B x 3], [B x 3]] - min and max XYZ coords
43 """
44 if dst_range is None:
45 dst_range = [
46 torch.zeros((src_range[0].shape[0], 3), device=src_range[0].device),
47 torch.ones((src_range[0].shape[0], 3), device=src_range[0].device),
48 ]
49
50 if pred_xyz.ndim == 4:
51 src_range = [x[:, None] for x in src_range]
52 dst_range = [x[:, None] for x in dst_range]
53
54 assert src_range[0].shape[0] == pred_xyz.shape[0]
55 assert dst_range[0].shape[0] == pred_xyz.shape[0]
56 assert src_range[0].shape[-1] == pred_xyz.shape[-1]
57 assert src_range[0].shape == src_range[1].shape
58 assert dst_range[0].shape == dst_range[1].shape
59 assert src_range[0].shape == dst_range[1].shape
60
61 src_diff = src_range[1][:, None, :] - src_range[0][:, None, :]
62 dst_diff = dst_range[1][:, None, :] - dst_range[0][:, None, :]
63 prop_xyz = (
64 ((pred_xyz - src_range[0][:, None, :]) * dst_diff) / src_diff
65 ) + dst_range[0][:, None, :]
66 return prop_xyz
67
68
69def scale_points(pred_xyz, mult_factor):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected