8. scoria.Quaternion module¶
-
class
scoria.Quaternion.
Quaternion
(s, x, y, z)¶ A class supporting quaternion arithmetic
-
add
(q2)¶ Adds two quaternions.
Parameters: q2 (scoria.Quaternion) – A quaternion, to be added to self Returns: A Quaternion, with the values corresponding to self + q2
-
copy
()¶ Returns a copy of self
-
invert
()¶ Takes the inverse of the quaternion for “division.”
Returns: A Quaternion, with the values corresponding to self^-1
-
load_from_mat
(m)¶ Converts a rotation matrix that is pure orthogonal (det(matrix)=1) into a Quaternion. Adapted from http://www.euclideanspace.com/maths/ geometry/rotations/conversions/matrixToQuaternion/index.htm
Parameters: m (numpy.array) – A 2D numpy.array representing a pure orthogonal matrix
-
minus
(q2)¶ Multiplies two quaternions.
Parameters: q2 (scoria.Quaternion) – A quaternion, to be subtracted from self - Returns:
- A Quaternion, with the values corresponding to self - q2
-
multiply
(q2)¶ Multiplies two quaternions.
Parameters: q2 (scoria.Quaternion) – A quaternion, to be multiplied with self Returns: A Quaternion, with the values corresponding to self * q2
-
normalize
()¶ Normalizes the quaternion.
Returns: A normalized Quaternion
-
rep_as_44_matrix
()¶ Creates a 4x4 matrix representation of the Quaternion.
Returns: A 4x4 numpy array
-
scale
(scalar)¶ Scales a quaternion.
Parameters: scalar (???) – the value to scale the quaternion by Returns: A Quaternion, with the values corresponding to self * scalar
-
to_matrix
()¶ Converts to a normalized 3x3 matrix.
Returns: A 3x3 numpy.array, corresponding to the quaternion
-