Quaternion¶
-
class
gala.coordinates.
Quaternion
(wxyz)[source]¶ Bases:
object
Quaternions for 3D rotations.
This is largely thanks to Jake Vanderplas: https://jakevdp.github.io/blog/2012/11/24/simple-3d-visualization-in-matplotlib/
Parameters: wxyz : array_like
A quaternion in vector representation. Order is assumed to be
(w,x,y,z)
.Attributes Summary
rotation_matrix
Compute the rotation matrix of the (normalized) quaternion. v_theta
Return the (v, theta)
equivalent of the (normalized) quaternion.Methods Summary
from_v_theta
(v, theta)Create a quaternion from unit vector v and rotation angle theta. random
()Randomly sample a Quaternion from a distribution uniform in 3D rotation angles. Attributes Documentation
-
rotation_matrix
¶ Compute the rotation matrix of the (normalized) quaternion.
Returns: R :
ndarray
A 3 by 3 rotation matrix (has shape
(3,3)
).
-
v_theta
¶ Return the
(v, theta)
equivalent of the (normalized) quaternion.Returns: v : float
theta : float
Methods Documentation
-
classmethod
from_v_theta
(v, theta)[source]¶ Create a quaternion from unit vector v and rotation angle theta.
Returns: q :
gala.coordinates.Quaternion
A
Quaternion
instance.
-
classmethod
random
()[source]¶ Randomly sample a Quaternion from a distribution uniform in 3D rotation angles.
https://www-preview.ri.cmu.edu/pub_files/pub4/kuffner_james_2004_1/kuffner_james_2004_1.pdf
Returns: q :
gala.coordinates.Quaternion
A randomly sampled
Quaternion
instance.
-