MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / rotation_6d_to_matrix

Function rotation_6d_to_matrix

utils/general_util.py:293–314  ·  view source on GitHub ↗

Converts 6D rotation representation by Zhou et al. [1] to rotation matrix using Gram--Schmidt orthogonalization per Section B of [1]. Args: d6: 6D rotation representation, of size (*, 6) Returns: batch of rotation matrices of size (*, 3, 3) [1] Zhou, Y., Barnes

(d6: torch.Tensor)

Source from the content-addressed store, hash-verified

291
292# https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/transforms/rotation_conversions.py
293def rotation_6d_to_matrix(d6: torch.Tensor) -> torch.Tensor:
294 """
295 Converts 6D rotation representation by Zhou et al. [1] to rotation matrix
296 using Gram--Schmidt orthogonalization per Section B of [1].
297 Args:
298 d6: 6D rotation representation, of size (*, 6)
299
300 Returns:
301 batch of rotation matrices of size (*, 3, 3)
302
303 [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
304 On the Continuity of Rotation Representations in Neural Networks.
305 IEEE Conference on Computer Vision and Pattern Recognition, 2019.
306 Retrieved from http://arxiv.org/abs/1812.07035
307 """
308
309 a1, a2 = d6[..., :3], d6[..., 3:]
310 b1 = F.normalize(a1, dim=-1)
311 b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
312 b2 = F.normalize(b2, dim=-1)
313 b3 = torch.cross(b1, b2, dim=-1)
314 return torch.stack((b1, b2, b3), dim=-2)
315
316
317def strands_from_signal_torch(signal,norm='backward'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected