Skip to content

pymath.multiply_quat

Daniel Flassig edited this page Jun 24, 2026 · 1 revision

Multiplies two quaternions, composing the rotations they represent.

This function is located in the pymath module. See pymath for the quaternion representation.

q = pymath.multiply_quat(q1, q2)
Parameter Type Description
q1 quaternion Left quaternion {x, y, z, w}.
q2 quaternion Right quaternion {x, y, z, w}.

Return value

Type Description
q A new quaternion, the product q1 * q2.

Notes:

  • Quaternion multiplication is not commutative: q1 * q2 ≠ q2 * q1 in general.
  • As a composition of rotations, pymath.multiply_quat(q1, q2) applies q2 first and then q1 (the same order as multiplying rotation matrices).
  • If both operands are unit quaternions, the result is a unit quaternion.

Example:

-- Two successive 90° rotations about z give a 180° rotation about z
local q90  = pymath.quat_from_rotation({0, 0, 1}, 90)
local q180 = pymath.multiply_quat(q90, q90)
-- q180 == {0, 0, 1, 0}

Version Support:

Minimum PYTHA Version: V27

See also:

pymath, pymath.invert_quat, pymath.rotate_by_quat

Clone this wiki locally