quaternions package¶
Submodules¶
quaternions.quaternion module¶
A module to hold and work with Quaternions Repo at: https://github.com/mjsobrep/quaternions
-
class
quaternions.quaternion.
Quaternion
(w, x, y, z, norm_error=1e-08)[source]¶ Bases:
object
A class to hold and work with quaternions
-
w
¶ The real component of the quaternion
-
x
¶ The i component of the quaternion
-
y
¶ The y component of the quaternion
-
z
¶ The z component of the quaternion
-
norm_error
¶ The maximum deviation from magnitude 1 for which a quaternion will be considered normalized
-
__init__
(w, x, y, z, norm_error=1e-08)[source]¶ Constructs a quaternion from individual components
Parameters: - w (int,float) – The real component of the quaternion
- x (int,float) – The i component of the quaternion
- y (int,float) – The j component of the quaternion
- z (int,float) – The k component of the quaternion
- norm_error (float) – The maximum deviation from magnitude 1 for which a quaternion will be considered normalized
-
almost_equal
(other, delta=1e-08)[source]¶ Determines whether a quaternion is approximately equal to another using a naive comparison of the 4 values w, x, y, z
Parameters: - other (Quaternion) – The quaternion with which to test equality
- delta (float) – The error range in which to define two quaternions equal
Returns:
-
conjugate
()[source]¶ Return the conjugate of the quaternion.
Returns: The conjugate of the quaternion
-
distance
(other)[source]¶ Return the rotational distance between two quaternions.
Parameters: other (Quaternion) – The other Returns: The angular distance between two quaternions
-
dot
(other)[source]¶ Return the quaternion dot product
Parameters: other (Quaternion) – Quaternion with which to calculate the dot product Returns: The dot product of the two quaternions
-
classmethod
from_axis_angle
(axis, angle)[source]¶ Constructs a quaternion from axis-angle measurements.
Parameters: - axis – A list of three numbers representing the axis of rotation.
- angle – A single number representing the rotation about the axis in radians
Returns: The constructed quaternion
-
classmethod
from_euler
(values, axes=['x', 'y', 'z'])[source]¶ Constructs w quaternion using w 3 member list of Euler angles, along with w list defining their rotation sequence. Based off of this: http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf
Parameters: - values (list of numbers) – 3 member list giving the rotations of the Euler angles in radians
- axes (list of chars) – 3 member list specifying the order of rotations
Returns: The constructed quaternion
-
classmethod
from_matrix
(matrix)[source]¶ Generates a Quaternion from a rotation matrix
Parameters: matrix – A rotation matrix, a list of 3, 3 member lists of numbers Returns: The constructed quaternion
-
classmethod
from_quaternion
(quaternion)[source]¶ Constructs a quaternion from another quaternion.
Parameters: quaternion (Quaternion) – The quaternion to copy Returns: The newly constructed quaternion
-
classmethod
from_rotation_vector
(vect)[source]¶ Constructs a quaternion from a rotation vector.
Parameters: vect – A rotation vector with angle as the magnitude and vector for the vector. Returns: The constructed quaternion
-
classmethod
from_translation
(translation)[source]¶ Generates a quaternion from a translation. Meant to be used along with the dual operator to generate dual quaternions
Parameters: - translation – A list of three numbers representing the (x,y,z)
- translation –
Returns: The quaternion created from the translation
-
get_euler
()[source]¶ Return an euler angle representation of the quaternion. Taken from [wikipedia](https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles)
Returns: The list of euler angles x,y,z
-
get_rotation_matrix
()[source]¶ Return the rotation matrix which this quaternion is equivalent to
Returns: The rotation matrix which this quaternion is equivalent to as a list of three lists of three elements each
-