pytransform3d.rotations.matrix_from_two_vectors

pytransform3d.rotations.matrix_from_two_vectors(a, b)[source]

Compute rotation matrix from two vectors.

We assume that the two given vectors form a plane so that we can compute a third, orthogonal vector with the cross product.

The x-axis will point in the same direction as a, the y-axis corresponds to the normalized vector rejection of b on a, and the z-axis is the cross product of the other basis vectors.

Parameters
aarray-like, shape (3,)

First vector, must not be 0

barray-like, shape (3,)

Second vector, must not be 0 or parallel to a

Returns
Rarray, shape (3, 3)

Rotation matrix

Raises
ValueError

If vectors are parallel or one of them is the zero vector

Examples using pytransform3d.rotations.matrix_from_two_vectors