find the quaternion used to rotate v0 to v1
(v0, v1)
| 385 | |
| 386 | |
| 387 | def 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 | |
| 400 | def qbetween_np(v0, v1): |
no test coverage detected