Skip to content

Instantly share code, notes, and snippets.

@jmbr
Created October 30, 2021 01:08
Show Gist options
  • Save jmbr/26522a3c58e677298d2cf56522543db3 to your computer and use it in GitHub Desktop.
Save jmbr/26522a3c58e677298d2cf56522543db3 to your computer and use it in GitHub Desktop.
Quick and dirty sampling of small rotation matrices
"""Quick and dirty sampling of small rotation matrices."""
import numpy as np
from scipy.linalg import expm
from scipy.spatial.transform import Rotation
n: int = 3 # Dimensions
epsilon: float = 1e-2 # Amplitude of the rotation
A = np.random.rand(n, n)
A = epsilon * (A - A.T) / 2.0
B = expm(A)
print(Rotation.from_matrix(B).as_euler('xyz', degrees=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment