skillfed

numpy-quaternion

Add a quaternion dtype to NumPy

numpy-quaternion v2024.0.13 1.1M downloads/30d#4,305 on PyPI658
Permissive license MIT AGING released

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-quaternion

uv

uv add numpy-quaternion

poetry

poetry add numpy-quaternion

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: AstronomyTopic :: Scientific/Engineering :: Physics

Tags

quaternion math numpyquaternion dtyperotation quaternionsquaternion arrays3d rotation representationquaternion operationsnumpy quaternion dtype
rotation-mathnumpy-extension3d-graphics

More Physics packages