I am using a method proposed by R. G. Reynolds to estimate attitude based on two vector measurements, taken from: https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19990052720.pdf

Suppose we measure 2 unit vectors $b_{1}$ and $b_{2}$ in the body frame, and we know the components in the inertial frame are $r_{1}$ and $r_{2}$. The attitude quaternion can be calculated:

$$ c = |(b_{1} - r_{1}) \times (b_{2} - r_{2})|^2 + ((b_{1} + r_{1})\cdot (b_{2} - r_{2}))^2$$

$$q = \frac{1}{\sqrt{c}} [b_{2} \cdot r_{1} - b_{1} \cdot r_{2}, (b_{1} - r_{1}) \times (b_{2} - r_{2})] $$

Where $c$ is a normalisation factor and $q$ is in the form $[w, \vec{v}]$.

I've been trying this method out and it works half the time, but occasionally all the elements of the quaternion are their negative. Is there a way around this problem?

I know there is also a singularity problem when the two vectors are parallel but I don't think this is the problem?

  • $\begingroup$ They must also obey handedness or they would flip. Cross product and all that. $\endgroup$
    – joojaa
    Mar 31 '18 at 11:39

In this answer I will represent a quaternion as $q = (q_r,q_v)$, with $q_r$ the real part and $q_v$ the complex vector part of the quaternion.

Rotating a 3D vector $x$ by a rotation represented by a unit quaternion can be done as follows

$$ (0,x') = (q_r,q_v)\,(0,x)\,(q_r,-q_v) =q\,(0,x)\,\bar{q} $$

with $\bar{q}$ the complex conjugate of $q$. Note that the complex conjugate of $-q$ is equal to $-\bar{q}$. So if the quaternion is negated $q^*=-q$ then the rotation with this gives

$$ (0,x') = q^*\,(0,x)\bar{q^*} = (-q)\,(0,x)\,(-\bar{q}) = q\,(0,x)\,\bar{q}) $$

which is the same end result. So $q$ and $-q$ represent the same rotation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.