A Python module that adds a native quaternion dtype to NumPy for efficient 3D rotation and orientation calculations.
numpy-quaternion is a Python library that adds a built-in quaternion data type to NumPy, enabling efficient and native handling of quaternions for 3D rotation and orientation calculations. It solves the problem of performing complex quaternion arithmetic within NumPy arrays by providing a dedicated dtype and optimized ufuncs. This allows developers to work with quaternions as seamlessly as they do with standard numeric types.
Scientists, engineers, and developers working in computer graphics, robotics, physics simulations, or any field requiring efficient 3D rotation representations. It is particularly useful for those already using NumPy for numerical computations.
Developers choose numpy-quaternion because it offers native NumPy integration with high-performance vectorized operations, eliminating the need for custom quaternion classes or slow loops. Its memory-efficient views and comprehensive conversion utilities make it a robust, production-ready solution for quaternion-based calculations.
Add built-in support for quaternions to numpy
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Adds a dedicated quaternion dtype, allowing quaternions to be used as first-class citizens in NumPy arrays, as demonstrated in the basic usage examples with direct array operations.
Implements core ufuncs like add, multiply, exp, and log for fast operations on quaternion arrays, enabling efficient batch processing without Python loops.
Quaternion arrays can be viewed as arrays of doubles without copying data, as shown with as_float_array, ensuring seamless interoperability and minimal memory overhead.
Provides utilities to convert between quaternions, rotation matrices, vectors, and Euler angles, though Euler angles are minimally supported due to their noted drawbacks.
The library is tightly coupled with NumPy, making it unsuitable for projects using alternative numerical libraries like PyTorch or JAX, limiting its flexibility.
Installing via pip requires a working C compiler, which can be a hurdle on systems without development tools, as noted in the installation instructions.
Functions like squad and mean rotor calculation require SciPy and Numba for optimal performance, adding extra dependencies and potential setup complexity.
The README explicitly states that Euler angles are 'awful' and provides only basic conversion functions, which may not satisfy users needing extensive Euler angle manipulations.