Transformations

2026.1.18 · deprecated · verified Wed Apr 15

Transformations is a Python library for calculating 4x4 matrices for translating, rotating, reflecting, scaling, shearing, projecting, orthogonalizing, and superimposing arrays of 3D homogeneous coordinates, as well as for converting between rotation matrices, Euler angles, and quaternions. It is no longer actively developed and is largely superseded by other libraries.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create rotation and translation matrices and apply them to a 3D point using homogeneous coordinates. It also shows how to concatenate transformations.

import numpy as np
import transformations as tf

# Create a rotation matrix around the Z-axis by 90 degrees (pi/2 radians)
angle = np.pi / 2
rotation_matrix = tf.rotation_matrix(angle, [0, 0, 1])

# Define a point in homogeneous coordinates (x, y, z, w=1)
point = np.array([1.0, 0.0, 0.0, 1.0])

# Apply the transformation
transformed_point = np.dot(rotation_matrix, point)

print(f"Original point: {point[:3]}")
print(f"Rotation matrix:\n{rotation_matrix}")
print(f"Transformed point: {transformed_point[:3]}")

# Create a translation matrix
translation_matrix = tf.translation_matrix([5.0, 2.0, 0.0])

# Concatenate transformations (apply rotation then translation)
combined_matrix = np.dot(translation_matrix, rotation_matrix)
combined_transformed_point = np.dot(combined_matrix, point)

print(f"\nCombined transformation matrix:\n{combined_matrix}")
print(f"Combined transformed point: {combined_transformed_point[:3]}")

view raw JSON →