CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pytransform3d

3D transformations for Python with comprehensive rotation representations, coordinate conversions, and visualization tools

Pending
Overview
Eval results
Files

transformations.mddocs/

Transformations

3D transformations combining rotation and translation in three dimensions (SE(3)). Supports homogeneous matrices, position-quaternions, dual quaternions, screw theory, and exponential coordinates with comprehensive conversion and composition operations.

Capabilities

Homogeneous Transform Operations

Operations for 4x4 homogeneous transformation matrices combining rotation and translation.

def check_transform(A2B, tolerance=1e-6, strict_check=True):
    """Validate homogeneous transformation matrix."""

def transform_from(R, p, strict_check=True):
    """
    Construct transformation matrix from rotation and translation.
    
    Parameters:
    - R: array-like, shape (3, 3) - Rotation matrix
    - p: array-like, shape (3,) - Translation vector
    - strict_check: bool, optional - Enable strict validation
    
    Returns:
    - A2B: array, shape (4, 4) - Homogeneous transformation matrix
    """

def invert_transform(A2B):
    """Invert transformation matrix efficiently."""

def concat(*transforms):
    """
    Concatenate multiple transformations.
    
    Parameters:
    - transforms: sequence of arrays, shape (4, 4) - Transformation matrices
    
    Returns:
    - result: array, shape (4, 4) - Composed transformation
    """

def transform(A2B, PA):
    """
    Transform points from frame A to frame B.
    
    Parameters:
    - A2B: array, shape (4, 4) - Transformation matrix
    - PA: array, shape (..., 3 or 4) - Points in frame A
    
    Returns:
    - PB: array, shape (..., 3 or 4) - Points in frame B
    """

def scale_transform(A2B, s_x, s_y, s_z):
    """Scale transformation components."""

def rotate_transform(A2B, R):
    """Apply additional rotation to transformation."""

def translate_transform(A2B, p):
    """Apply additional translation to transformation."""

Point and Vector Operations

Operations for homogeneous points and direction vectors.

def vector_to_point(v):
    """Convert 3D vector to homogeneous point."""

def vectors_to_points(V):
    """Convert array of vectors to homogeneous points."""

def vector_to_direction(v):
    """Convert 3D vector to homogeneous direction."""

def vectors_to_directions(V):
    """Convert array of vectors to homogeneous directions."""

Position-Quaternion Representation

Operations for compact position-quaternion representation (7 parameters).

def check_pq(pq, tolerance=1e-6, strict_check=True):
    """Validate position-quaternion representation."""

def pq_from_transform(A2B):
    """
    Extract position-quaternion from transformation.
    
    Parameters:
    - A2B: array, shape (4, 4) - Transformation matrix
    
    Returns:
    - pq: array, shape (7,) - Position-quaternion [x, y, z, qw, qx, qy, qz]
    """

def transform_from_pq(pq):
    """Construct transformation from position-quaternion."""

def pq_slerp(start, end, t):
    """Spherical linear interpolation between position-quaternions."""

Dual Quaternion Operations

Operations for dual quaternion representation of transformations.

def check_dual_quaternion(dq, unit=True, tolerance=1e-6, strict_check=True):
    """Validate dual quaternion representation."""

def norm_dual_quaternion(dq):
    """Normalize dual quaternion."""

def dual_quaternion_from_transform(A2B):
    """Convert transformation to dual quaternion."""

def transform_from_dual_quaternion(dq):
    """Convert dual quaternion to transformation."""

def dual_quaternion_from_pq(pq):
    """Convert position-quaternion to dual quaternion."""

def pq_from_dual_quaternion(dq):
    """Convert dual quaternion to position-quaternion."""

def concatenate_dual_quaternions(dq1, dq2):
    """Compose dual quaternions."""

def dual_quaternion_sclerp(start, end, t):
    """Screw linear interpolation between dual quaternions."""

def dual_quaternion_power(dq, t):
    """Dual quaternion power operation."""

def dq_conj(dq):
    """Full conjugate of dual quaternion."""

def dq_q_conj(dq):
    """Quaternion conjugate of dual quaternion."""

def dq_prod_vector(dq, v):
    """Transform vector using dual quaternion."""

Screw Theory Operations

Operations based on screw theory for describing rigid body motions.

def check_screw_parameters(s, tolerance=1e-6, strict_check=True):
    """Validate screw parameters."""

def check_screw_axis(S, tolerance=1e-6, strict_check=True):
    """Validate screw axis representation."""

def check_exponential_coordinates(Stheta, tolerance=1e-6, strict_check=True):
    """Validate exponential coordinates."""

def transform_from_exponential_coordinates(Stheta):
    """
    Convert exponential coordinates to transformation.
    
    Parameters:
    - Stheta: array, shape (6,) - Exponential coordinates
    
    Returns:
    - A2B: array, shape (4, 4) - Transformation matrix
    """

def exponential_coordinates_from_transform(A2B):
    """Extract exponential coordinates from transformation."""

def screw_parameters_from_screw_axis(S, theta):
    """Convert screw axis and angle to screw parameters."""

def screw_axis_from_screw_parameters(s):
    """Extract screw axis from screw parameters."""

def screw_matrix_from_screw_axis(S):
    """Convert screw axis to screw matrix."""

def screw_axis_from_screw_matrix(S_hat):
    """Convert screw matrix to screw axis."""

def dual_quaternion_from_screw_parameters(s):
    """Convert screw parameters to dual quaternion."""

def screw_parameters_from_dual_quaternion(dq):
    """Convert dual quaternion to screw parameters."""

Transform Interpolation

Interpolation operations for smooth transformation transitions.

def transform_sclerp(start, end, t):
    """
    Screw linear interpolation between transformations.
    
    Parameters:
    - start: array, shape (4, 4) - Start transformation
    - end: array, shape (4, 4) - End transformation  
    - t: float - Interpolation parameter [0, 1]
    
    Returns:
    - interp: array, shape (4, 4) - Interpolated transformation
    """

def transform_power(A2B, t):
    """Transformation power operation."""

Random Generation

Functions for generating random transformations.

def random_transform(random_state=None):
    """Generate random transformation matrix."""

def random_screw_axis(random_state=None):
    """Generate random screw axis."""

def random_exponential_coordinates(random_state=None):
    """Generate random exponential coordinates."""

Mathematical Operations

Advanced mathematical operations for transformation analysis.

def adjoint_from_transform(A2B):
    """
    Compute adjoint matrix from transformation.
    
    Parameters:
    - A2B: array, shape (4, 4) - Transformation matrix
    
    Returns:
    - adj: array, shape (6, 6) - Adjoint matrix
    """

def transform_log_from_transform(A2B):
    """Convert transformation to matrix logarithm."""

def transform_from_transform_log(T_log):
    """Convert matrix logarithm to transformation."""

def left_jacobian_SE3(Stheta):
    """Left Jacobian for SE(3) group."""

def left_jacobian_SE3_inv(Stheta):
    """Inverse left Jacobian for SE(3)."""

Usage Examples

Basic Transform Operations

import numpy as np
import pytransform3d.transformations as pt
import pytransform3d.rotations as pr

# Create transformation from rotation and translation
R = pr.matrix_from_euler([0.1, 0.2, 0.3], "xyz", extrinsic=True)
p = [1.0, 2.0, 3.0]
T1 = pt.transform_from(R=R, p=p)

# Create another transformation (pure translation)
T2 = pt.transform_from(np.eye(3), [0.5, 0, 0])

# Compose transformations
T_composed = pt.concat(T1, T2)

# Transform points
points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]])
points_transformed = pt.transform(T_composed, points)

Position-Quaternion Operations

import pytransform3d.transformations as pt

# Convert transformation to position-quaternion
T = pt.transform_from(np.eye(3), [1, 2, 3])
pq = pt.pq_from_transform(T)
print(f"Position-quaternion: {pq}")

# Interpolate between poses
pq1 = pt.pq_from_transform(pt.transform_from(np.eye(3), [0, 0, 0]))
pq2 = pt.pq_from_transform(pt.transform_from(np.eye(3), [1, 1, 1]))
pq_mid = pt.pq_slerp(pq1, pq2, 0.5)

# Convert back to transformation
T_mid = pt.transform_from_pq(pq_mid)

Screw Theory

import numpy as np
import pytransform3d.transformations as pt

# Define screw motion (pure translation along x-axis)
screw_axis = np.array([0, 0, 0, 1, 0, 0])  # [omega_x, omega_y, omega_z, v_x, v_y, v_z]
theta = 1.0  # motion magnitude

# Convert to exponential coordinates
Stheta = screw_axis * theta

# Get transformation matrix
T = pt.transform_from_exponential_coordinates(Stheta)
print(f"Transformation from screw motion:\n{T}")

# Convert back to verify
Stheta_recovered = pt.exponential_coordinates_from_transform(T)
print(f"Recovered exponential coordinates: {Stheta_recovered}")

Dual Quaternion Operations

import pytransform3d.transformations as pt
import pytransform3d.rotations as pr

# Create transformation
R = pr.matrix_from_euler([0, 0, np.pi/4], "xyz", extrinsic=True)
T = pt.transform_from(R=R, p=[1, 0, 0])

# Convert to dual quaternion
dq = pt.dual_quaternion_from_transform(T)

# Compose with another transformation
T2 = pt.transform_from(np.eye(3), [0, 1, 0])
dq2 = pt.dual_quaternion_from_transform(T2)
dq_composed = pt.concatenate_dual_quaternions(dq, dq2)

# Convert back to transformation
T_composed = pt.transform_from_dual_quaternion(dq_composed)

Install with Tessl CLI

npx tessl i tessl/pypi-pytransform3d

docs

batch-operations.md

batch-rotations.md

camera.md

coordinates.md

editor.md

index.md

plot-utils.md

rotations.md

trajectories.md

transform-manager.md

transformations.md

uncertainty.md

urdf.md

visualization.md

tile.json