MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / qbetween

Function qbetween

text2motion/utils/quaternion.py:387–397  ·  view source on GitHub ↗

find the quaternion used to rotate v0 to v1

(v0, v1)

Source from the content-addressed store, hash-verified

385
386
387def qbetween(v0, v1):
388 '''
389 find the quaternion used to rotate v0 to v1
390 '''
391 assert v0.shape[-1] == 3, 'v0 must be of the shape (*, 3)'
392 assert v1.shape[-1] == 3, 'v1 must be of the shape (*, 3)'
393
394 v = torch.cross(v0, v1)
395 w = torch.sqrt((v0 ** 2).sum(dim=-1, keepdim=True) * (v1 ** 2).sum(dim=-1, keepdim=True)) + (v0 * v1).sum(dim=-1,
396 keepdim=True)
397 return qnormalize(torch.cat([w, v], dim=-1))
398
399
400def qbetween_np(v0, v1):

Callers 1

qbetween_npFunction · 0.85

Calls 1

qnormalizeFunction · 0.85

Tested by

no test coverage detected