quaternions package

Submodules

quaternions.quaternion module

A module to hold and work with Quaternions

class quaternions.quaternion.Quaternion(w, x, y, z, norm_error=1e-08)[source]

Bases: object

__init__(w, x, y, z, norm_error=1e-08)[source]
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
  • delta

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:

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_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

inverse()[source]

Return the inverse of the quaternion. Specifically, this is the multiplicative inverse, such that multiplying the inverse of q by q yields the multiplicative identity.

Returns:The multiplicative inverse of the quaternion
norm()[source]

Return the norm of the quaternion

Returns:The norm of the quaternion
unit()[source]

Return the unit Quaternion :returns: Unit quaternion

Module contents