Content deleted Content added
Ebernardes (talk | contribs) m Added ref general conversion |
Ebernardes (talk | contribs) Replaced formulas and algorithm with an equivalent one that has less numerical problems Tag: Disambiguation links added |
||
Line 189:
A direct formula for the conversion from a quaternion to Euler angles in any of the 12 possible sequences exists<ref>{{cite journal |last1=Bernardes |first1=Evandro |last2=Viollet |first2=Stéphane |title=Quaternion to Euler angles conversion: A direct, general and computationally efficient method |journal=PLOS ONE |date=10 November 2022 |volume=17 |issue=11 |pages=e0276302 |doi=10.1371/journal.pone.0276302 |url=https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0276302 |language=en |issn=1932-6203}}</ref>. For the rest of this section, the formula for the sequence '''Body 3-2-1''' will be shown.
:<math>\begin{bmatrix}
Line 195:
\end{bmatrix} =
\begin{bmatrix}
\mbox{arctan} \
2 \, \mbox{
\mbox{arctan} \
\end{bmatrix} </math>
Note, however, that the [[arctan]], [[arcsin]] and [[
Moreover, typical implementations of [[arcsin]] and [[arccos]], also might have some numerical disadvantages near zero and one. Besides having these problems, some implementations use the equivalent expression<ref>{{cite journal|last1=Blanco|first1=Jose-Luis|title=A tutorial on se (3) transformation parameterizations and on-manifold optimization|journal=University of Malaga, Tech. Rep|date=2010|citeseerx=10.1.1.468.5407}}</ref>:
:<math> \theta = \mbox{arcsin} (2(q_0 q_2 - q_3 q_1)) </math>
To safely generate all the orientations one needs to replace the arctan functions in computer code by [[atan2]]:
:<math>\begin{bmatrix}
Line 206 ⟶ 211:
\end{bmatrix} =
\begin{bmatrix}
\mbox{atan2} \left(2(q_0 q_1 + q_2 q_3),1 - 2(q_1^2 + q_2^2)\right) \\
2 \, \mbox{
\mbox{atan2} \left(2(q_0 q_3 + q_1 q_2),1 - 2(q_2^2 + q_3^2)\right)
\end{bmatrix} </math>
Line 226 ⟶ 231:
};
// this implementation assumes normalized quaternion
EulerAngles ToEulerAngles(Quaternion
EulerAngles angles;
Line 235 ⟶ 241:
// pitch (y-axis rotation)
double sinp = std::sqrt(1 + 2 * (q.w * q.
// yaw (z-axis rotation)
|