API Documentation

This is the detailed documentation of all public classes and functions. You can also search for specific modules, classes, or functions in the Index.

pytransform3d.rotations

Rotations in three dimensions - SO(3).

See SO(3): 3D Rotations for more information.

Input Validation Functions

check_matrix(R[, tolerance, strict_check])

Input validation of a rotation matrix.

check_skew_symmetric_matrix(V[, tolerance, …])

Input validation of a skew-symmetric matrix.

check_axis_angle(a)

Input validation of axis-angle representation.

check_compact_axis_angle(a)

Input validation of compact axis-angle representation.

check_quaternion(q[, unit])

Input validation of quaternion representation.

check_quaternions(Q[, unit])

Input validation of quaternion representation.

check_rotor(rotor)

Input validation of rotor.

Conversions to Rotation Matrix

See also Euler Angles for conversions from and to Euler angles that have been omitted here for the sake of brevity.

passive_matrix_from_angle(basis, angle)

Compute passive rotation matrix from rotation about basis vector.

active_matrix_from_angle(basis, angle)

Compute active rotation matrix from rotation about basis vector.

matrix_from_two_vectors(a, b)

Compute rotation matrix from two vectors.

matrix_from_axis_angle(a)

Compute rotation matrix from axis-angle.

matrix_from_compact_axis_angle(a)

Compute rotation matrix from compact axis-angle.

matrix_from_quaternion(q)

Compute rotation matrix from quaternion.

matrix_from_rotor(rotor)

Compute rotation matrix from rotor.

Conversions to Axis-Angle

axis_angle_from_matrix(R[, strict_check, check])

Compute axis-angle from rotation matrix.

axis_angle_from_quaternion(q)

Compute axis-angle from quaternion.

axis_angle_from_compact_axis_angle(a)

Compute axis-angle from compact axis-angle representation.

compact_axis_angle(a)

Compute 3-dimensional axis-angle from a 4-dimensional one.

compact_axis_angle_from_matrix(R)

Compute compact axis-angle from rotation matrix.

compact_axis_angle_from_quaternion(q)

Compute compact axis-angle from quaternion (logarithmic map).

Conversions to Quaternion

quaternion_from_matrix(R[, strict_check])

Compute quaternion from rotation matrix.

quaternion_from_axis_angle(a)

Compute quaternion from axis-angle.

quaternion_from_compact_axis_angle(a)

Compute quaternion from compact axis-angle (exponential map).

quaternion_xyzw_from_wxyz(q_wxyz)

Converts from w, x, y, z to x, y, z, w convention.

quaternion_wxyz_from_xyzw(q_xyzw)

Converts from x, y, z, w to w, x, y, z convention.

Conversions to Rotor

rotor_from_two_directions(v_from, v_to)

Construct the rotor that rotates one vector to another.

rotor_from_plane_angle(B, angle)

Compute rotor from plane bivector and angle.

Quaternion and Axis-Angle Operations

axis_angle_from_two_directions(a, b)

Compute axis-angle representation from two direction vectors.

axis_angle_slerp(start, end, t)

Spherical linear interpolation.

concatenate_quaternions(q1, q2)

Concatenate two quaternions.

q_prod_vector(q, v)

Apply rotation represented by a quaternion to a vector.

q_conj(q)

Conjugate of quaternion.

quaternion_slerp(start, end, t)

Spherical linear interpolation.

quaternion_dist(q1, q2)

Compute distance between two quaternions.

quaternion_diff(q1, q2)

Compute the rotation in angle-axis format that rotates q2 into q1.

quaternion_gradient(Q[, dt])

Time-derivatives of a sequence of quaternions.

quaternion_integrate(Qd[, q0, dt])

Integrate angular velocities to quaternions.

Rotors

wedge(a, b)

Outer product of two vectors (also exterior or wedge product).

plane_normal_from_bivector(B)

Convert bivector to normal vector of a plane.

geometric_product(a, b)

Geometric product of two vectors.

concatenate_rotors(rotor1, rotor2)

Concatenate rotors.

rotor_reverse(rotor)

Invert rotor.

rotor_apply(rotor, v)

Compute rotation matrix from rotor.

rotor_slerp(start, end, t)

Spherical linear interpolation.

Plotting

plot_basis([ax, R, p, s, ax_s, strict_check])

Plot basis of a rotation matrix.

plot_axis_angle([ax, a, p, s, ax_s])

Plot rotation axis and angle.

plot_bivector([ax, a, b, ax_s])

Plot bivector from wedge product of two vectors a and b.

Testing

assert_axis_angle_equal(a1, a2, *args, **kwargs)

Raise an assertion if two axis-angle are not approximately equal.

assert_compact_axis_angle_equal(a1, a2, …)

Raise an assertion if two axis-angle are not approximately equal.

assert_quaternion_equal(q1, q2, *args, **kwargs)

Raise an assertion if two quaternions are not approximately equal.

assert_rotation_matrix(R, *args, **kwargs)

Raise an assertion if a matrix is not a rotation matrix.

Utility Functions

norm_vector(v)

Normalize vector.

norm_matrix(R)

Normalize rotation matrix.

norm_angle(a)

Normalize angle to (-pi, pi].

norm_axis_angle(a)

Normalize axis-angle representation.

norm_compact_axis_angle(a)

Normalize compact axis-angle representation.

perpendicular_to_vectors(a, b)

Compute perpendicular vector to two other vectors.

angle_between_vectors(a, b[, fast])

Compute angle between two vectors.

vector_projection(a, b)

Orthogonal projection of vector a on vector b.

plane_basis_from_normal(plane_normal)

Compute two basis vectors of a plane from the plane’s normal vector.

random_vector([random_state, n])

Generate an nd vector with normally distributed components.

random_axis_angle([random_state])

Generate random axis-angle.

random_compact_axis_angle([random_state])

Generate random compact axis-angle.

random_quaternion([random_state])

Generate random quaternion.

cross_product_matrix(v)

Generate the cross-product matrix of a vector.

Deprecated Functions

matrix_from([R, a, q, e_xyz, e_zyx])

Compute rotation matrix from another representation.

matrix_from_angle(basis, angle)

Compute passive rotation matrix from rotation about basis vector.

matrix_from_euler_xyz(e)

Compute passive rotation matrix from intrinsic xyz Tait-Bryan angles.

matrix_from_euler_zyx(e)

Compute passive rotation matrix from intrinsic zyx Tait-Bryan angles.

euler_xyz_from_matrix(R[, strict_check])

Compute xyz Euler angles from passive rotation matrix.

euler_zyx_from_matrix(R[, strict_check])

Compute zyx Euler angles from passive rotation matrix.

assert_euler_xyz_equal(e_xyz1, e_xyz2, …)

Raise an assertion if two xyz Euler angles are not approximately equal.

assert_euler_zyx_equal(e_zyx1, e_zyx2, …)

Raise an assertion if two zyx Euler angles are not approximately equal.

pytransform3d.transformations

Transformations in three dimensions - SE(3).

See SE(3): 3D Transformations for more information.

Utility Functions

random_transform([random_state])

Generate random transform.

random_screw_axis([random_state])

Generate random screw axis.

norm_exponential_coordinates(Stheta)

Normalize exponential coordinates of transformation.

Input Validation Functions

check_transform(A2B[, strict_check])

Input validation of transform.

check_pq(pq)

Input validation for position and orientation quaternion.

check_screw_parameters(q, s_axis, h)

Input validation of screw parameters.

check_screw_axis(screw_axis)

Input validation of screw axis.

check_exponential_coordinates(Stheta)

Input validation for exponential coordinates of transformation.

check_screw_matrix(screw_matrix[, …])

Input validation for screw matrix.

check_transform_log(transform_log[, …])

Input validation for logarithm of transformation.

check_dual_quaternion(dq[, unit])

Input validation of dual quaternion representation.

Conversions to Transformation Matrix

transform_from(R, p[, strict_check])

Make transformation from rotation matrix and translation.

translate_transform(A2B, p[, strict_check, …])

Sets the translation of a transform.

rotate_transform(A2B, R[, strict_check, check])

Sets the rotation of a transform.

transform_from_pq(pq)

Compute transformation matrix from position and quaternion.

transform_from_exponential_coordinates(Stheta)

Compute transformation matrix from exponential coordinates.

transform_from_transform_log(transform_log)

Compute transformation from matrix logarithm of transformation.

transform_from_dual_quaternion(dq)

Compute transformation matrix from dual quaternion.

Conversions to Position and Quaternion

pq_from_transform(A2B[, strict_check])

Compute position and quaternion from transformation matrix.

pq_from_dual_quaternion(dq)

Compute position and quaternion from dual quaternion.

Conversions to Screw Parameters

screw_parameters_from_screw_axis(screw_axis)

Compute screw parameters from screw axis.

screw_parameters_from_dual_quaternion(dq)

Compute screw parameters from dual quaternion.

Conversions to Screw Axis

screw_axis_from_screw_parameters(q, s_axis, h)

Compute screw axis representation from screw parameters.

screw_axis_from_exponential_coordinates(Stheta)

Compute screw axis and theta from exponential coordinates.

screw_axis_from_screw_matrix(screw_matrix)

Compute screw axis from screw matrix.

Conversions to Exponential Coordinates

exponential_coordinates_from_transform(A2B)

Compute exponential coordinates from transformation matrix.

exponential_coordinates_from_screw_axis(…)

Compute exponential coordinates from screw axis and theta.

exponential_coordinates_from_transform_log(…)

Compute exponential coordinates from logarithm of transformation.

Conversions to Screw Matrix

screw_matrix_from_screw_axis(screw_axis)

Compute screw matrix from screw axis.

screw_matrix_from_transform_log(transform_log)

Compute screw matrix from logarithm of transformation.

Conversions to Matrix Logarithm

transform_log_from_exponential_coordinates(Stheta)

Compute matrix logarithm of transformation from exponential coordinates.

transform_log_from_screw_matrix(…)

Compute matrix logarithm of transformation from screw matrix and theta.

transform_log_from_transform(A2B[, strict_check])

Compute matrix logarithm of transformation from transformation.

Conversions to Dual Quaternions

dual_quaternion_from_transform(A2B)

Compute dual quaternion from transformation matrix.

dual_quaternion_from_pq(pq)

Compute dual quaternion from position and quaternion.

dual_quaternion_from_screw_parameters(q, …)

Compute dual quaternion from screw parameters.

Apply Transformations

concat(A2B, B2C[, strict_check, check])

Concatenate transformations.

invert_transform(A2B[, strict_check, check])

Invert transform.

transform(A2B, PA[, strict_check])

Transform point or list of points or directions.

vector_to_point(v)

Convert 3D vector to position.

vectors_to_points(V)

Convert 3D vectors to positions.

vector_to_direction(v)

Convert 3D vector to direction.

vectors_to_directions(V)

Convert 3D vectors to directions.

scale_transform(A2B[, s_xr, s_yr, s_zr, …])

Scale a transform from A to reference frame B.

adjoint_from_transform(A2B[, strict_check, …])

Compute adjoint representation of a transformation matrix.

Dual Quaternion Operations

dq_conj(dq)

Conjugate of dual quaternion.

dq_q_conj(dq)

Quaternion conjugate of dual quaternion.

concatenate_dual_quaternions(dq1, dq2)

Concatenate dual quaternions.

dq_prod_vector(dq, v)

Apply transform represented by a dual quaternion to a vector.

dual_quaternion_power(dq, t)

Compute power of unit dual quaternion with respect to scalar.

dual_quaternion_sclerp(start, end, t)

Screw linear interpolation (ScLERP) for dual quaternions.

Plotting

plot_transform([ax, A2B, s, ax_s, name, …])

Plot transform.

plot_screw([ax, q, s_axis, h, theta, A2B, …])

Plot transformation about and along screw axis.

Testing

assert_transform(A2B, *args, **kwargs)

Raise an assertion if the transform is not a homogeneous matrix.

assert_unit_dual_quaternion(dq, *args, **kwargs)

Raise an assertion if the dual quaternion does not have unit norm.

assert_unit_dual_quaternion_equal(dq1, dq2, …)

Raise an assertion if unit dual quaternions are not approximately equal.

assert_screw_parameters_equal(q1, s_axis1, …)

Raise an assertion if two sets of screw parameters are not similar.

pytransform3d.batch_rotations

Batch operations on rotations in three dimensions - SO(3).

Conversions from this module operate on batches of orientations or rotations and can be orders of magnitude faster than a loop of individual conversions.

All functions operate on nd arrays, where the last dimension (vectors) or the last two dimensions (matrices) contain individual rotations.

norm_vectors(V[, out])

Normalize vectors.

angles_between_vectors(A, B)

Compute angle between two vectors.

active_matrices_from_angles(basis, angles[, out])

Compute active rotation matrices from rotation about basis vectors.

active_matrices_from_intrinsic_euler_angles(…)

Compute active rotation matrices from intrinsic Euler angles.

active_matrices_from_extrinsic_euler_angles(…)

Compute active rotation matrices from extrinsic Euler angles.

matrices_from_compact_axis_angles([A, axes, …])

Compute rotation matrices from compact axis-angle representations.

axis_angles_from_matrices(Rs[, traces, out])

Compute compact axis-angle representations from rotation matrices.

cross_product_matrices(V)

Generate the cross-product matrices of vectors.

matrices_from_quaternions(Q[, …])

Compute rotation matrices from quaternions.

quaternions_from_matrices(Rs[, out])

Compute quaternions from rotation matrices.

quaternion_slerp_batch(start, end, t)

Spherical linear interpolation for a batch of steps.

batch_q_conj(Q)

Conjugate of quaternions.

batch_concatenate_quaternions(Q1, Q2[, out])

Concatenate two batches of quaternions.

batch_quaternion_wxyz_from_xyzw(Q_xyzw[, out])

Converts from x, y, z, w to w, x, y, z convention.

batch_quaternion_xyzw_from_wxyz(Q_wxyz[, out])

Converts from w, x, y, z to x, y, z, w convention.

pytransform3d.trajectories

Trajectories in three dimensions - SE(3).

Conversions from this module operate on batches of poses or transformations and can be 400 to 1000 times faster than a loop of individual conversions.

invert_transforms(A2Bs)

Invert transforms.

concat_one_to_many(A2B, B2Cs)

Concatenate transformation A2B with multiple transformations B2C.

concat_many_to_one(A2Bs, B2C)

Concatenate multiple transformations A2B with transformation B2C.

transforms_from_pqs(P[, normalize_quaternions])

Get sequence of homogeneous matrices from positions and quaternions.

pqs_from_transforms(A2Bs)

Get sequence of positions and quaternions from homogeneous matrices.

exponential_coordinates_from_transforms(A2Bs)

Compute exponential coordinates from transformations.

transforms_from_exponential_coordinates(Sthetas)

Compute transformations from exponential coordinates.

dual_quaternions_from_pqs(pqs)

Get dual quaternions from positions and quaternions.

pqs_from_dual_quaternions(dqs)

Get positions and quaternions from dual quaternions.

batch_dq_conj(dqs)

Conjugate of dual quaternions.

batch_concatenate_dual_quaternions(dqs1, dqs2)

Concatenate dual quaternions.

batch_dq_prod_vector(dqs, V)

Apply transforms represented by a dual quaternions to vectors.

plot_trajectory([ax, P, …])

Plot pose trajectory.

pytransform3d.coordinates

Conversions between coordinate systems to represent positions.

cartesian_from_cylindrical(p)

Convert cylindrical coordinates to Cartesian coordinates.

cartesian_from_spherical(p)

Convert spherical coordinates to Cartesian coordinates.

cylindrical_from_cartesian(p)

Convert Cartesian coordinates to cylindrical coordinates.

cylindrical_from_spherical(p)

Convert spherical coordinates to cylindrical coordinates.

spherical_from_cartesian(p)

Convert Cartesian coordinates to spherical coordinates.

spherical_from_cylindrical(p)

Convert cylindrical coordinates to spherical coordinates.

pytransform3d.transform_manager

Manage complex chains of transformations.

See Managing Transformations for more information.

TransformManager([strict_check, check])

Manage transformations between frames.

pytransform3d.editor

Modify transformations visually.

TransformEditor(transform_manager, base_frame)

GUI to edit transformations.

pytransform3d.urdf

Load transformations from URDF files.

See Managing Transformations for more information.

UrdfTransformManager([strict_check, check])

Transformation manager that can load URDF files.

Link()

Link from URDF file.

Joint()

Joint from URDF file.

Geometry(frame, mesh_path, package_dir, color)

Geometrical object.

Box(frame, mesh_path, package_dir, color)

Geometrical object: box.

Sphere(frame, mesh_path, package_dir, color)

Geometrical object: sphere.

Cylinder(frame, mesh_path, package_dir, color)

Geometrical object: cylinder.

Mesh(frame, mesh_path, package_dir, color)

Geometrical object: mesh.

parse_urdf(urdf_xml[, mesh_path, …])

Parse information from URDF file.

initialize_urdf_transform_manager(tm, …)

Initializes transform manager from previously parsed URDF data.

pytransform3d.camera

Transformations related to cameras.

See Camera for more information.

make_world_grid([n_lines, …])

Generate grid in world coordinate frame.

make_world_line(p1, p2, n_points)

Generate line in world coordinate frame.

cam2sensor(P_cam, focal_length[, kappa])

Project points from 3D camera coordinate system to sensor plane.

sensor2img(P_sensor, sensor_size, image_size)

Project points from 2D sensor plane to image coordinate system.

world2image(P_world, cam2world, sensor_size, …)

Project points from 3D world coordinate system to 2D image.

plot_camera([ax, M, cam2world, …])

Plot camera in world coordinates.

pytransform3d.plot_utils

Utilities for plotting.

make_3d_axis(ax_s[, pos, unit, n_ticks])

Generate new 3D axis.

remove_frame(ax[, left, bottom, right, top])

Remove axis and scale bbox.

plot_vector([ax, start, direction, s, …])

Plot Vector.

plot_length_variable([ax, start, end, name, …])

Plot length with text at its center.

plot_box([ax, size, A2B, ax_s, wireframe, …])

Plot box.

plot_sphere([ax, radius, p, ax_s, …])

Plot sphere.

plot_cylinder([ax, length, radius, …])

Plot cylinder.

plot_mesh([ax, filename, A2B, s, ax_s, …])

Plot mesh.

plot_ellipsoid([ax, radii, A2B, ax_s, …])

Plot ellipsoid.

plot_capsule([ax, A2B, height, radius, …])

Plot capsule.

plot_cone([ax, height, radius, A2B, ax_s, …])

Plot cone.

Arrow3D(xs, ys, zs, *args, **kwargs)

A Matplotlib patch that represents an arrow in 3D.

Frame(A2B[, label, s])

A Matplotlib artist that displays a frame represented by its basis.

LabeledFrame(A2B[, label, s])

Displays a frame represented by its basis with axis labels.

Trajectory(H[, show_direction, n_frames, s])

A Matplotlib artist that displays a trajectory.

pytransform3d.visualizer

Optional 3D renderer based on Open3D’s visualizer.

figure([window_name, width, height, …])

Create a new figure.

Figure([window_name, width, height, …])

The top level container for all the plot elements.

Artist()

Abstract base class for objects that can be rendered.

Line3D(P[, c])

A line.

Frame(A2B[, label, s])

Coordinate frame.

Trajectory(H[, n_frames, s, c])

Trajectory of poses.

Sphere([radius, A2B, resolution, c])

Sphere.

Box([size, A2B, c])

Box.

Cylinder([length, radius, A2B, resolution, …])

Cylinder.

Mesh(filename[, A2B, s, c])

Mesh.

Ellipsoid(radii[, A2B, resolution, c])

Ellipsoid.

Capsule([height, radius, A2B, resolution, c])

Capsule.

Cone([height, radius, A2B, resolution, c])

Cone.

Graph(tm, frame[, show_frames, …])

Graph of connected frames.