pytransform3d.rotations.pick_closest_quaternion

pytransform3d.rotations.pick_closest_quaternion(quaternion, target_quaternion)[source]

Resolve quaternion ambiguity and pick the closest one to the target.

Warning

There are always two quaternions that represent the exact same orientation: q and -q.

Parameters:
quaternionarray-like, shape (4,)

Quaternion (w, x, y, z) of which we are unsure whether we want to select quaternion or -quaternion.

target_quaternionarray-like, shape (4,)

Target quaternion (w, x, y, z) to which we want to be close.

Returns:
closest_quaternionarray, shape (4,)

Quaternion that is closest (Euclidean norm) to the target quaternion.