3D Transformations for Python

3.15.0 · active · verified Thu Apr 16

pytransform3d is a Python library for 3D transformations, offering tools to manipulate and visualize 3D poses, rotations (matrices, quaternions, axis-angle), translations, trajectories, and meshes. It emphasizes conventions that are common in robotics and computer vision. The current version is 3.15.0, and the project maintains an active release cadence with frequent updates and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a 3D transformation (rotation + translation) using axis-angle representation and then visualize it using matplotlib utilities provided by pytransform3d. It shows a basic use of `transformations` and `plot_utils` modules.

import numpy as np
import pytransform3d.transformations as ptf
import pytransform3d.plot_utils as ppu
import matplotlib.pyplot as plt

# Define a transformation: rotate 90 degrees around Z-axis, then translate (1, 0, 0)
A2B = ptf.transform_from_axis_angle([0, 0, 1, np.deg2rad(90)], np.array([1, 0, 0]))

# Create a 3D axis for plotting
ax = ppu.make_3d_axis(ax_s=2, n_ticks=2)

# Plot the transformation
ppu.plot_transform(ax, A2B, s=0.5)

# Set title and display
ax.set_title("Basic Transformation Plot")
plt.show()

view raw JSON →