This function multiplies each of the n
rows of pose
by a different rotation matrix. Is it possible to avoid the loop by maybe using a 3d tensor of rotation matrices?
def transform(ref, pose):
n, d = pose.shape
p = ref[:, :d].copy()
c = np.cos(ref[:, 2])
s = np.sin(ref[:, 2])
for i in range(n):
p[i,:2] += pose[i,:2].dot(np.array([[c[i], s[i]], [-s[i], c[i]]]))
return p