Skip to main content

A pure-numpy Python library for 3D rotation representations

Project description

rotations-py

A pure-numpy Python library for 3D rotation representations. Convert freely between four representations, compose rotations, and apply them to vectors.

Representations

Class Stores Use when
SO3 3×3 rotation matrix applying rotations, interfacing with linear algebra
Quaternion (w, x, y, z) unit quaternion interpolation, game engines, aerospace
AxisAngle unit axis + angle (radians) human-readable construction
Screw rotation vector w = axis · θ optimization, robotics, Lie group math

Installation

uv add rotations-py

Usage

import numpy as np
from rotations import SO3, Quaternion, AxisAngle, Screw

# construct
r = AxisAngle([0, 0, 1], np.pi/2)   # 90° around z

# convert between representations
r.to_so3()
r.to_quaternion()
r.to_screw()

# apply to a vector
r @ [1, 0, 0]           # → [0, 1, 0]

# compose two rotations
r1 = AxisAngle([0, 0, 1], np.pi/2)
r2 = AxisAngle([1, 0, 0], np.pi/2)
r3 = r1 @ r2            # result is same type as r1

# inverse
~r                       # AxisAngle for 90° around -z
r @ ~r                   # → identity

Conversion graph

SO3  ←→  Quaternion  ←→  AxisAngle  ←→  Screw

See description.md for the full math behind each conversion.

Development

To run tests

uv run pytest

To run the linter and formatter

uv run ruff check           # check lint
uv run ruff format --check  # check format
uv run ruff check --fix     # lint and auto-fix
uv run ruff format          # format and fix

To run the static type checker

uv run mypy rotations/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotations_py-0.1.0.tar.gz (55.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotations_py-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file rotations_py-0.1.0.tar.gz.

File metadata

  • Download URL: rotations_py-0.1.0.tar.gz
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rotations_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0bce9f7b84a106ec43afc9c213f68a920e584e217ebb64fb3f28101b413724b3
MD5 255059d122c6e0bad1ecafa7528bf882
BLAKE2b-256 9ec1a92b58cb44a6ce7b93132f7e349bb0adc728e0a666e3b70a5dd6cfbdb4ac

See more details on using hashes here.

File details

Details for the file rotations_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rotations_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rotations_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec21bca6d39165877dc9e8f275540b4981a55a764ecaf29533b714f4505c2e23
MD5 8018839a3bf53f4807c85cc83e7fbd19
BLAKE2b-256 6d119c125190e326ad5d9e3dd5d5f82fed17fbf4d0dd0fea4e0679cc4b1714ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page