MCPcopy
hub / github.com/NVlabs/imaginaire / trans_vec_homo

Function trans_vec_homo

imaginaire/model_utils/gancraft/mc_utils.py:63–81  ·  view source on GitHub ↗

r"""3-dimensional Homogeneous matrix and regular vector multiplication Convert v to homogeneous vector, perform M-V multiplication, and convert back Note that this function does not support autograd. Args: m (4 x 4 tensor): a homogeneous matrix v (3 tensor): a 3-d vector

(m, v, is_vec=False)

Source from the content-addressed store, hash-verified

61
62
63def trans_vec_homo(m, v, is_vec=False):
64 r"""3-dimensional Homogeneous matrix and regular vector multiplication
65 Convert v to homogeneous vector, perform M-V multiplication, and convert back
66 Note that this function does not support autograd.
67
68 Args:
69 m (4 x 4 tensor): a homogeneous matrix
70 v (3 tensor): a 3-d vector
71 vec (bool): if true, v is direction. Otherwise v is point
72 """
73 if is_vec:
74 v = torch.tensor([v[0], v[1], v[2], 0], dtype=v.dtype)
75 else:
76 v = torch.tensor([v[0], v[1], v[2], 1], dtype=v.dtype)
77 v = torch.mv(m, v)
78 if not is_vec:
79 v = v / v[3]
80 v = v[:3]
81 return v
82
83
84def cumsum_exclusive(tensor, dim):

Callers 1

world2localMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected