Last active
November 19, 2018 12:38
-
-
Save rpapallas/39d5a28bf7a705cdd5b970da3f2eeacc to your computer and use it in GitHub Desktop.
Apply rotations to quaternions quick utility tool using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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