Skip to main content

transform3d

Handy classes for working with trees of 3d transformations.

Uses scipy.spatial.transform.Rotation for stable conversions between rotation representations.

install

$ pip3 install transform3d

convention

a_t_b denotes b relative to a, such that a point in frame b, p_b, is transformed to frame a by: p_a = a_t_b @ p_b (Note that @ is the matmul operator in python.) This provides easy to read series of transformations: a_t_d = a_t_b @ b_t_c @ c_t_d.

usage

import numpy as np
from transform3d import Transform, SceneNode, SceneState

# basic Transform usage
a_t_b = Transform(p=(1, 0, 0), rotvec=(0, 0, 0))
b_t_c = Transform(p=(0, 0, 1), rpy=(0, 0, np.pi / 2))
a_t_c = a_t_b @ b_t_c
c_t_a = a_t_c.inv

# transform a point from a's frame to c's frame
p_a = (1, 0, 0)
p_c = c_t_a @ p_a
# or multiple points
p_a = np.random.randn(2, 3)  # two points (x, y, z)
p_c = c_t_a @ p_a

# rotate vectors
v_a = (1, 0, 0)
v_c = c_t_a.rotate(v_a)
# or screws (6d, eg. force-torque)
s_a = (1, 0, 0, 1, 0, 0)
s_c = c_t_a.rotate(v_a)

# using SceneNode to build a tree
root = SceneNode()
a = SceneNode(parent=root)
b = SceneNode(parent=root)
c = SceneNode(parent=b)
# or:
root, a, b, c = SceneNode.n(4)
root.adopt(
    a,
    b.adopt(c)
)

# set node transforms in relation to parents
state = SceneState()
state[a] = Transform(p=(1, 0, 0), rpy=(np.pi, 0, 0))
state[b] = Transform(rotvec=(0, 90, 0), degrees=True)
state[c] = Transform(quat=(0, 0, 0, 1))

# calculate transforms between nodes
c_t_a = c.p(a, state)  # type: Transform

# solve for transforms
c_t_a_desired = Transform(p=(1, 2, 3), R=np.eye(3))
state[b] = b.solve(c, a, c_t_a_desired, state)
assert c.p(a, state).equals(c_t_a_desired)

Metadata

Release files for transform3d 0.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 transform3d 0.0.4
File Size Uploaded
transform3d-0.0.4.tar.gz 5.6 kB Details

Built distribution (wheel)

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

Total release size: 11.7 kB

Release files / transform3d-0.0.4.tar.gz

Download URL transform3d-0.0.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2b7b0da34c8c745f84a9547a9357b48cc3fc9fc547b8883ad7af992a9081eba4
BLAKE2b-256 checksum
How to use checksums
02454a497f8e4bcb842304e06eeaff7859a91e8fe929b45ecbc09804a1503a98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release files / transform3d-0.0.4-py3-none-any.whl

Download URL transform3d-0.0.4-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
727f568ee36fd43ee67c4477ba7368a4c20faab539871d278fbf4f5f0c65d89a
BLAKE2b-256 checksum
How to use checksums
83803017a8c3788a67c336d332110a60c64e5bce159128009c031a8e83900f22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

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