psychopy.tools.mathtools.multQuat

psychopy.tools.mathtools.multQuat(q0, q1, out=None, dtype=None)[source]

Multiply quaternion q0 and q1.

The orientation of the returned quaternion is the combination of the input quaternions.

Parameters:
  • q0 (array_like) – Quaternions to multiply in form [x, y, z, w] where w is real and x, y, z are imaginary components. If 2D (Nx4) arrays are specified, quaternions are multiplied row-wise between each array.

  • q1 (array_like) – Quaternions to multiply in form [x, y, z, w] where w is real and x, y, z are imaginary components. If 2D (Nx4) arrays are specified, quaternions are multiplied row-wise between each array.

  • out (ndarray, optional) – Optional output array. Must be same shape and dtype as the expected output if out was not specified.

  • dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns:

Combined orientations of q0 amd q1.

Return type:

ndarray

Notes

  • Quaternions are normalized prior to multiplication.

Examples

Combine the orientations of two quaternions:

a = quatFromAxisAngle([0, 0, -1], 45.0, degrees=True)
b = quatFromAxisAngle([0, 0, -1], 90.0, degrees=True)
c = multQuat(a, b)  # rotates 135 degrees about -Z axis

Back to top