You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daniel Flassig edited this page Jun 24, 2026
·
1 revision
Builds the unit quaternion that represents a rotation by angle about axis.
This function is located in the pymath module. See pymath for the quaternion representation.
q=pymath.quat_from_rotation(axis, angle)
Parameter
Type
Description
axis
{x,y,z} or string
Rotation axis, given either as a 3-vector or as an axis keyword string ("x", "y", "z", "-x", "-y", "-z"), exactly as for local coordinate systems. It is normalized internally, so it need not be a unit vector.
angle
number
Rotation angle in degrees.
Return value
Type
Description
q
A new unit quaternion {x, y, z, w} describing the rotation.
Notes:
axis need not be a unit vector; it is normalized internally. A zero-length (or near-zero) axis falls back to an implementation-defined unit axis, so pass a well-defined non-zero axis for predictable results.
-- 90° rotation about the z-axislocalq=pymath.quat_from_rotation({0, 0, 1}, 90)
-- q == {0, 0, 0.70710678, 0.70710678}-- the axis may also be given as a keyword:localq2=pymath.quat_from_rotation("z", 90) -- same result