numpy-quaternion
Add a quaternion dtype to NumPy
What it is and what it does
numpy-quaternion extends NumPy with a native quaternion dtype, allowing quaternions to be used directly in NumPy arrays and operations. Quaternions are represented as a scalar (w) followed by three imaginary components (x, y, z), stored as double-precision floats. The package implements standard ufuncs (add, multiply, exp, log, conjugate, etc.) that run efficiently on quaternion arrays, and provides conversion functions to rotate between quaternion, rotation matrix, rotation vector, Euler angle, and spherical coordinate representations.
The package is built on NumPy and scipy, making it suitable for scientific and engineering applications that need 3D rotations or orientation calculations. Installation typically requires a C compiler, though prebuilt wheels are available for Python 3.10–3.13 on macOS, Linux, and Windows. The code is production-stable and actively maintained, with comprehensive documentation and examples.
Use it for:
- Represent and manipulate 3D rotations in robotics, aerospace, or computer graphics applications
- Perform batch quaternion arithmetic on large arrays without Python loops
- Convert between rotation representations (matrices, Euler angles, rotation vectors) for different algorithms
- Compute exponentials, logarithms, and other transcendental functions on quaternion arrays
- Store orientation data compactly in NumPy arrays while maintaining numerical precision
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds a quaternion dtype to NumPy, enabling efficient quaternion arithmetic and array operations with native NumPy integration.
Yes, if you need quaternion support in NumPy-based scientific code. The package is production-stable, actively maintained, MIT-licensed, and has no known vulnerabilities. Install friction is moderate due to C compilation, but prebuilt wheels are available for common platforms. Not necessary if you only need basic quaternion math or prefer pure-Python alternatives.
Install
numpy-quaternion on PyPI
pip
pip install numpy-quaternionuv
uv add numpy-quaternionpoetry
poetry add numpy-quaternionInstalling numpy-quaternion
Before you install
Medium install friction due to C compilation requirement. Package is actively maintained with recent releases; last commit 2025-12-15. Supports Python 3.10–3.13 with prebuilt wheels for common platforms (macOS, Linux x86_64, ARM, Windows).
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
import numpy as np
import quaternion
q1 = np.quaternion(1, 2, 3, 4)
q2 = np.quaternion(5, 6, 7, 8)
result = q1 * q2
a = np.array([q1, q2])
exponentials = np.exp(a)
Requires a working C compiler for pip installation; prebuilt wheels available for common platforms. Python 3.10–3.13 required.
Verify before relying
- Whether scipy is used at runtime or only as a build/test dependency
- Performance characteristics compared to pure-Python quaternion libraries
- Specific use cases in astronomy or physics applications beyond rotation representation
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<3.15,>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | aging — 263 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,142,139/month — #4,305 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: numpy_quaternion-2024.0.13-cp310-cp310-macosx_10_9_universal2.whl; numpy_quaternion-2024.0.13-cp310-cp310-macosx_10_9_x86_64.whl; numpy_quaternion-2024.0.13-cp310-cp310-macosx_11_0_arm64.whl; numpy_quaternion-2024.0.13-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; numpy_quaternion-2024.0.13-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; numpy_quaternion-2024.0.13-cp310-cp310-win_amd64.whl; numpy_quaternion-2024.0.13-cp311-cp311-macosx_10_9_universal2.whl; numpy_quaternion-2024.0.13-cp311-cp311-macosx_10_9_x86_64.whl; numpy_quaternion-2024.0.13-cp311-cp311-macosx_11_0_arm64.whl; numpy_quaternion-2024.0.13-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; numpy_quaternion-2024.0.13-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; numpy_quaternion-2024.0.13-cp311-cp311-win_amd64.whl; numpy_quaternion-2024.0.13-cp312-cp312-macosx_10_13_universal2.whl; numpy_quaternion-2024.0.13-cp312-cp312-macosx_10_13_x86_64.whl; numpy_quaternion-2024.0.13-cp312-cp312-macosx_11_0_arm64.whl; numpy_quaternion-2024.0.13-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; numpy_quaternion-2024.0.13-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; numpy_quaternion-2024.0.13-cp312-cp312-win_amd64.whl; numpy_quaternion-2024.0.13-cp313-cp313-macosx_10_13_universal2.whl; numpy_quaternion-2024.0.13-cp313-cp313-macosx_10_13_x86_64.whl
Tags
More Physics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
pydicomPydicom reads, modifies, and writes DICOM…
permissive · top 5,000 on PyPI
albumentationsAlbumentations applies image transformations to…
permissive · top 5,000 on PyPI
CoolPropCoolProp provides thermodynamic and transport…
permissive · top 5,000 on PyPI
pyquaternionProvides quaternion representation,…
permissive · top 5,000 on PyPI
transformationsCalculates 4x4 homogeneous transformation…
permissive · top 5,000 on PyPI
transforms3dConverts between different 3D geometric…
permissive · top 15,000 on PyPI
euclid3Provides 2D and 3D vector, matrix, quaternion,…
unclear · top 15,000 on PyPI
romaRoMa provides differentiable conversions…
permissive · top 15,000 on PyPI
numpydanticNumpydantic adds type annotations and…
permissive · top 15,000 on PyPI
pyerfaPyERFA wraps the ERFA C library (Essential…
permissive · top 5,000 on PyPI
array-api-extraProvides extra array manipulation functions…
permissive · top 15,000 on PyPI
nptypingProvides type hints and runtime type checking…
permissive · top 15,000 on PyPI
pydantic-numpyIntegrates NumPy arrays into Pydantic models…
permissive · top 15,000 on PyPI