Skip to main content

SO3/SE3 operations on any backend

Project description

nanomanifold

Fast, batched and differentiable SO3/SE3 transforms for any backend (NumPy, PyTorch, JAX, ...) Works directly on arrays, defined as:

  • SO3: unit quaternions [w, x, y, z] for 3D rotations, shape (..., 4)
  • SE3: concatenated [quat, translation], shape (..., 7)
import numpy as np
from nanomanifold import SO3, SE3

# Rotations stored as quaternion arrays [w,x,y,z]
q = SO3.from_axis_angle(np.array([0, 0, 1]), np.pi/4)  # 45° around Z
points = np.array([[1, 0, 0], [0, 1, 0]])
rotated = SO3.rotate_points(q, points)

# Rigid transforms stored as 7D arrays [quat, translation]
T = SE3.from_rt(q, np.array([1, 0, 0]))  # rotation + translation
transformed = SE3.transform_points(T, points)

Features

Array-based API — all functions operate directly on arrays from any backend
Backend agnostic — works with NumPy, PyTorch, JAX, CuPy, Dask, and more
Batched operations — process thousands of transforms at once
Differentiable — automatic gradients where supported (PyTorch/JAX)
Memory efficient — quaternions instead of matrices
Numerically stable — handles edge cases and singularities

Quick Start

Rotations (SO3)

from nanomanifold import SO3

# Create rotations
q1 = SO3.from_axis_angle([1, 0, 0], np.pi/2)    # 90° around X
q2 = SO3.from_euler([0, 0, np.pi/4])            # 45° around Z
q3 = SO3.from_matrix(rotation_matrix)

# Compose and interpolate
q_combined = SO3.multiply(q1, q2)
q_halfway = SO3.slerp(q1, q2, t=0.5)

# Apply to points
points = np.array([[1, 0, 0], [0, 1, 0]])
rotated = SO3.rotate_points(q_combined, points)

Rigid Transforms (SE3)

from nanomanifold import SE3

# Create transforms
T1 = SE3.from_rt(q1, [1, 2, 3])               # rotation + translation
T2 = SE3.from_matrix(transformation_matrix)

# Compose transforms
T_combined = SE3.multiply(T1, T2)
T_inverse = SE3.inverse(T_combined)

# Apply to points
transformed = SE3.transform_points(T_combined, points)

API Reference

SO3 (3D Rotations)

Function Input → Output Description
from_axis_angle(axis, angle) (...,3), (...) → (...,4) Create from axis-angle
from_euler(angles) (...,3) → (...,4) Create from Euler angles
from_matrix(R) (...,3,3) → (...,4) Create from rotation matrix
multiply(q1, q2) (...,4), (...,4) → (...,4) Compose rotations
slerp(q1, q2, t) (...,4), (...,4), (...) → (...,4) Spherical interpolation
rotate_points(q, points) (...,4), (...,N,3) → (...,N,3) Rotate 3D points

SE3 (Rigid Transforms)

Function Input → Output Description
from_rt(q, t) (...,4), (...,3) → (...,7) Create from rotation + translation
from_matrix(T) (...,4,4) → (...,7) Create from 4×4 matrix
multiply(T1, T2) (...,7), (...,7) → (...,7) Compose transforms
inverse(T) (...,7) → (...,7) Invert transform
transform_points(T, points) (...,7), (...,N,3) → (...,N,3) Transform 3D points

Installation

pip install nanomanifold

License

MIT

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

nanomanifold-0.1.1.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

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

nanomanifold-0.1.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file nanomanifold-0.1.1.tar.gz.

File metadata

  • Download URL: nanomanifold-0.1.1.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.17

File hashes

Hashes for nanomanifold-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aaceb7e03caac120b2fc09b4d07475549cb9384fbe3d1d87be0637677606fc39
MD5 c9737253dc9ef7e5cfea42c950bad5eb
BLAKE2b-256 131a7e69e53c03ab867136e9456c0d66b2912fbf0680fa8c86417e1fed86974e

See more details on using hashes here.

File details

Details for the file nanomanifold-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nanomanifold-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2ba825b50002a183650c8aaba5ec1ff54a03dbaec270994ef1aab3ede25bca2
MD5 59ee25837897ca5528dc93e043e87372
BLAKE2b-256 5c1679ed69c08aa69bca437fe0fd1609f21205684f88861f0333b19533bbc732

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