Skip to content

RandomRotate

RandomRotate(degrees: Union[Tuple[float, float], float], axis: int = 0)

Bases: BaseTransform

Rotates the node positions pos by a random angle (in degrees) around an axis, sampled uniformly from degrees (with mx.random).

Parameters:

Name Type Description Default
degrees Union[Tuple[float, float], float]

The (min, max) rotation angles, or a value d for (-d, d).

required
axis int

The rotation axis (for 3D positions). Default: 0

0

Example:

from mlx_graphs.transforms import RandomRotate

graph = RandomRotate(15, axis=2)(graph)
Source code in mlx_graphs/transforms/point_cloud.py
def __init__(self, degrees: Union[Tuple[float, float], float], axis: int = 0):
    if isinstance(degrees, (int, float)):
        degrees = (-abs(degrees), abs(degrees))
    if not isinstance(degrees, (tuple, list)) or len(degrees) != 2:
        raise ValueError("degrees must be a number or a (min, max) tuple")
    self.degrees = tuple(degrees)
    self.axis = axis

from mlx_graphs.transforms import RandomRotate · mlx_graphs/transforms/point_cloud.py