rowan
raw JSON → 1.3.2 verified Fri May 01 auth: no python
A Python library for performing quaternion operations using NumPy arrays. Provides functions for quaternion creation, normalization, rotation, interpolation, and conversion between quaternions and other rotation representations (e.g., rotation matrices, axis-angle). Current version: 1.3.2, released 2023-04-03. Release cadence is irregular.
pip install rowan Common errors
error AttributeError: module 'rowan' has no attribute 'from_axis_angle' ↓
cause Older versions of rowan (<1.0?) use different function names, e.g., `rowan.from_axisangle` (no underscore). Check installed version.
fix
Upgrade to latest rowan:
pip install --upgrade rowan or use the correct old name: rowan.from_axisangle. error TypeError: Object arrays are not supported ↓
cause Input numpy array has dtype=object, often because it contains mixed types or is created from a ragged list.
fix
Ensure array has homogeneous numeric dtype, e.g.,
np.array(..., dtype=np.float64). Warnings
gotcha rowan expects inputs as numpy arrays, not lists. Passing plain Python lists may cause unexpected errors or silently produce wrong results. ↓
fix Always convert lists to np.array before passing to rowan functions.
gotcha Quaternion conventions: rowan uses the scalar-first convention (q = [w, x, y, z]). Some other libraries (e.g., scipy) use scalar-last. Mixing conventions will cause incorrect rotations. ↓
fix When interfacing with other libraries, convert conventions explicitly: for rowan use [w, x, y, z].
gotcha The function `rowan.from_axis_angle` expects the axis to be normalized. If the axis is not unit length, the quaternion will represent a rotation with incorrect angle. ↓
fix Normalize the axis vector using `axis / np.linalg.norm(axis)` before passing.
Imports
- rowan wrong
from rowan import *correctimport rowan
Quickstart
import rowan
import numpy as np
# Create a quaternion from axis-angle (radians)
axis = np.array([0, 0, 1])
angle = np.pi / 2
q = rowan.from_axis_angle(axis, angle)
# Rotate a vector
v = np.array([1, 0, 0])
v_rot = rowan.rotate(q, v)
print(v_rot) # [0, 1, 0]
# Convert to rotation matrix
R = rowan.to_matrix(q)
print(R)