Skip to content

Instantly share code, notes, and snippets.

@rpapallas
Last active November 19, 2018 12:38
Show Gist options
  • Save rpapallas/39d5a28bf7a705cdd5b970da3f2eeacc to your computer and use it in GitHub Desktop.
Save rpapallas/39d5a28bf7a705cdd5b970da3f2eeacc to your computer and use it in GitHub Desktop.
Apply rotations to quaternions quick utility tool using Python
# Requires pyquaternion -- pip install --user pyquaternion
from pyquaternion import Quaternion
import math
def apply_rotation(q1, axis, angle):
q2 = Quaternion(axis=axis, angle=angle)
result = q1 * q2
return result.elements
q1 = Quaternion(1, 0, 0, 0)
print(apply_rotation(q1, [0, 0, 1], math.pi))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment