Skip to content

pymath.interpolate_quat

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

Interpolates between two quaternions along the shortest arc.

This is the spherical linear interpolation, commonly known as SLERP: the result moves at constant angular velocity along the shortest great-circle arc between the two orientations.

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

q = pymath.interpolate_quat(q1, q2, t)
Parameter Type Description
q1 quaternion Start quaternion {x, y, z, w} (returned for t = 0).
q2 quaternion End quaternion {x, y, z, w} (returned for t = 1).
t number Interpolation parameter in [0, 1].

Return value

Type Description
q A new quaternion interpolated between q1 and q2.

Notes:

  • At t = 0 the result equals q1; at t = 1 it equals q2.
  • q1 and q2 should be unit quaternions for the interpolation to describe a pure rotation.

Example:

local q0   = {0, 0, 0, 1}   -- identity (0°)
local q180 = {0, 0, 1, 0}   -- 180° about z
local q    = pymath.interpolate_quat(q0, q180, 0.5)
-- q == {0, 0, 0.70710678, 0.70710678}   -- 90° about z

Version Support:

Minimum PYTHA Version: V27

See also:

pymath, pymath.multiply_quat, pymath.quat_from_rotation

Clone this wiki locally