Skip to main content

euler

Generic badge Checked with Mypy PyPI version shields.io PyPI status

A library for Euler angle computation and conversion.

Installation

You can install the library from PyPI as follows:

pip install -U euler

Usage

The library is designed to be imported directly, analogously to NumPy:

>>> from numpy import pi
>>> import euler

The 12 possible axis triples available for Euler angles can be accessed as follows:

>>> euler.AXIS_TRIPLES
('xzx', 'xyx', 'yxy', 'yzy', 'zyz', 'zxz', 'xzy', 'xyz', 'yxz', 'yzx', 'zyx', 'zxy')

For static typing purposes, the corresponding literal type alias is euler.AxisTriple.

The euler.matrix_<pqr> functions, where <pqr> is an axis triple, can be used to compute a rotation matrix from Euler angles:

>>> h = euler.matrix_zxz(pi/2, pi/2, pi/2)
>>> h.round(3)
array([[-0., -0.,  1.],
       [ 0., -1., -0.],
       [ 1.,  0.,  0.]])

The euler.angles_<pqr> functions, where <pqr> is an axis triple, can be used to compute Euler angles from a rotation matrix:

>>> a, b, c = euler.angles_xyz(h)
>>> a, b, c
(3.141592653589793, 1.5707963267948966, 0.0)

The euler.convert_<pqr>_<uvw> functions, finally, can be used to convert Euler angles from axis triple <pqr> to axis triple <uvw>:

>>> euler.convert_zxz_xyz(pi/2, pi/2, pi/2)
(3.141592653589793, 1.5707963267948966, 0.0)

The functions euler.matrix, euler.angles and euler.convert serve an analogous purpose, but take the axis triple(s) as string parameter(s):

>>> h = euler.matrix("zxz", pi/2, pi/2, pi/2)
>>> h.round(3)
array([[-0., -0.,  1.],
       [ 0., -1., -0.],
       [ 1.,  0.,  0.]])
>>> a, b, c = euler.angles("xyz", h)
>>> a, b, c
(3.141592653589793, 1.5707963267948966, 0.0)
>>> euler.convert("zxz", "xyz", pi/2, pi/2, pi/2)
(3.141592653589793, 1.5707963267948966, 0.0)

The angles and convert functions take an optional tol argument, which defaults to 1e-8: when the middle angle of the result is within tol radians of gimbal lock, it is set to its value at gimbal lock and the third angle is set to zero. The result then differs from the input rotation by at most about tol. Away from gimbal lock, and for any tol down to about 1e-14, results are accurate to rounding error:

>>> euler.convert_zxz_zyz(0.1, 1e-5, 0.2, tol=1e-14)
(-1.4707963267948967, 1e-05, 1.7707963267948965)

The conversion functions are generated by tools/generate_convert.py.

Matrix calculations are originally taken from https://ntrs.nasa.gov/citations/19770019231, and have been independently verified (see the test folder).

License

LGPLv3 © Spooqy

Metadata

Release files for euler 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for euler 1.0.4
File Size Uploaded Provenance Actions
euler-1.0.4.tar.gz 27.4 kB Without provenance Details for euler-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for euler 1.0.4
File Interpreter ABI Platform Actions
euler-1.0.4-py3-none-any.whl Python 3 none any Details for euler-1.0.4-py3-none-any.whl

Total release size: 52.4 kB

Release files / euler-1.0.4.tar.gz

Download URL euler-1.0.4.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dc0df4eafcf7a4f24066b277f42fdc5cd3940b38b4468b24daa48b95a40ea55f
BLAKE2b-256 checksum
How to use checksums
4ad3803a9d88193a0c6011b8a993d1686bd0f748fc59f28f941a47d306454947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / euler-1.0.4-py3-none-any.whl

Download URL euler-1.0.4-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20b662ef8271b13d394e535d67d0bfb5285f9b26bdeba32ca94995accc749f2f
BLAKE2b-256 checksum
How to use checksums
7479855c70d7030ce83e6b29c55e82f06d7b6f01dc5c06d00f520e84b25718a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Security for euler 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page