def __truediv__(self, other):
""" Quaternion division with either scalars or quaternions.
The division with a scalar returns the quaternion with all elements divided
by the scalar.
The division with a quaternion returns q = q1 / q2 = q1 * q2^-1.
"""
if isinstance(other, Quaternion):
return self * other.inverse()
elif isinstance(other, Number):
q = self.q.copy()
q_out = q / np.float64(other)
return Quaternion(q=q_out)
else:
assert False, "Division is only defined for scalars or quaternions."
评论列表
文章目录