skrobot.coordinates.math.quaternion_distance¶
- skrobot.coordinates.math.quaternion_distance(q1, q2, absolute=False)[source]¶
Return the distance of quaternion.
- Parameters:
q1 (list or numpy.ndarray) –
q2 (list or numpy.ndarray) – [w, x, y, z] order
absolute (bool) – if True, return distance accounting for the sign ambiguity.
- Returns:
diff_theta – distance of q1 and q2 in radian.
- Return type:
Examples
>>> from skrobot.coordinates.math import quaternion_distance >>> quaternion_distance([1, 0, 0, 0], [1, 0, 0, 0]) 0.0 >>> quaternion_distance([1, 0, 0, 0], [0, 1, 0, 0]) 3.141592653589793 >>> distance = quaternion_distance( [1, 0, 0, 0], [0.8660254, 0, 0.5, 0]) >>> np.rad2deg(distance) 60.00000021683236