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

Function random_rotations

utils/general_util.py:458–473  ·  view source on GitHub ↗

Generate random rotations as 3x3 rotation matrices. Args: n: Number of rotation matrices in a batch to return. dtype: Type to return. device: Device of returned tensor. Default: if None, uses the current device for the default tensor type. Returns:

(
    n: int, dtype: Optional[torch.dtype] = None)

Source from the content-addressed store, hash-verified

456
457
458def random_rotations(
459 n: int, dtype: Optional[torch.dtype] = None) -> torch.Tensor:
460 """
461 Generate random rotations as 3x3 rotation matrices.
462
463 Args:
464 n: Number of rotation matrices in a batch to return.
465 dtype: Type to return.
466 device: Device of returned tensor. Default: if None,
467 uses the current device for the default tensor type.
468
469 Returns:
470 Rotation matrices as tensor of shape (n, 3, 3).
471 """
472 quaternions = random_quaternions(n, dtype=dtype)
473 return quaternion_to_matrix(quaternions)
474
475
476def quaternion_to_matrix(quaternions: torch.Tensor) -> torch.Tensor:

Callers

nothing calls this directly

Calls 2

random_quaternionsFunction · 0.85
quaternion_to_matrixFunction · 0.85

Tested by

no test coverage detected