MCPcopy Create free account
hub / github.com/MotrixLab/insactor / random_rotations

Function random_rotations

data/rotation_utils/conversions.py:339–355  ·  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, device: Optional[int] = None
)

Source from the content-addressed store, hash-verified

337
338
339def random_rotations(
340 n: int, dtype: Optional[torch.dtype] = None, device: Optional[int] = None
341) -> torch.Tensor:
342 """
343 Generate random rotations as 3x3 rotation matrices.
344
345 Args:
346 n: Number of rotation matrices in a batch to return.
347 dtype: Type to return.
348 device: Device of returned tensor. Default: if None,
349 uses the current device for the default tensor type.
350
351 Returns:
352 Rotation matrices as tensor of shape (n, 3, 3).
353 """
354 quaternions = random_quaternions(n, dtype=dtype, device=device)
355 return quaternion_to_matrix(quaternions)
356
357
358

Callers 1

random_rotationFunction · 0.85

Calls 2

random_quaternionsFunction · 0.85
quaternion_to_matrixFunction · 0.70

Tested by

no test coverage detected