Post · 1 min read· p. 306

Cosine of inner products

ahrs.utils.metrics.qcip(q1: ndarray, q2: ndarray) → float : The cosine of inner products between two unit quaternions q1\mathbf{q}_1 and :mathbf{q}_2` as defined in [Huy09]:

code
d(q1,q2)=arccos⁡(∣q1⋅q2∣)d(\mathbf{q}_1, \mathbf{q}_2) = \arccos(|\mathbf{q}_1\cdot\mathbf{q}_2|)
The error lies within: [0, π2\frac{\pi}{2}] Parameters: : - **q1** (*numpy.ndarray*) – First quaternion, or set of quaternions, to compare. - **q2** (*numpy.ndarray*) – Second quaternion, or set of quaternions, to compare. Returns: : **d** – Cosine of inner products of quaternions. Return type: : float Raises: : - **ValueError** – If the quaternions are not of the same shape. - **TypeError** – If the quaternions are not of type list or numpy.ndarray. Examples ```default

q1 = ahrs.Quaternion(random=True) q1.view() Quaternion([ 0.94185064, 0.04451339, -0.00622856, 0.33301221])

q2 = ahrs.Quaternion(random=True) q2.view() Quaternion([-0.51041283, -0.38336653, 0.76929238, -0.0264211 ])

ahrs.utils.qcip(q1, q2) 1.0339974504196667

ahrs.utils.qcip(q1, -q1) 0.0 ```