2020-08-27 03:28:38 +08:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
2021-10-26 03:34:27 +08:00
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
2022-06-08 02:13:03 +08:00
< meta name = "generator" content = "Doxygen 1.9.4" / >
2020-08-27 03:28:38 +08:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > Algorithms_in_C: 3D Quaternion operations< / title >
< link href = "../../tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../jquery.js" > < / script >
< script type = "text/javascript" src = "../../dynsections.js" > < / script >
< link href = "../../navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../resize.js" > < / script >
< script type = "text/javascript" src = "../../navtreedata.js" > < / script >
< script type = "text/javascript" src = "../../navtree.js" > < / script >
< link href = "../../search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../search/searchdata.js" > < / script >
< script type = "text/javascript" src = "../../search/search.js" > < / script >
< script type = "text/x-mathjax-config" >
2021-10-26 03:34:27 +08:00
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
2020-08-27 03:28:38 +08:00
});
< / script >
< script type = "text/javascript" async = "async" src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js" > < / script >
< link href = "../../doxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
2022-01-15 04:11:27 +08:00
< tr id = "projectrow" >
< td id = "projectalign" >
2021-10-26 03:34:27 +08:00
< div id = "projectname" > Algorithms_in_C< span id = "projectnumber" >   1.0.0< / span >
2020-08-27 03:28:38 +08:00
< / div >
< div id = "projectbrief" > Set of algorithms implemented in C.< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2022-06-08 02:13:03 +08:00
<!-- Generated by Doxygen 1.9.4 -->
2020-08-27 03:28:38 +08:00
< script type = "text/javascript" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
2020-08-27 03:28:38 +08:00
/* @license-end */
< / script >
< script type = "text/javascript" src = "../../menudata.js" > < / script >
< script type = "text/javascript" src = "../../menu.js" > < / script >
< script type = "text/javascript" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2020-08-27 03:28:38 +08:00
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
2021-10-26 03:34:27 +08:00
/* @license-end */
< / script >
2020-08-27 03:28:38 +08:00
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2020-08-27 03:28:38 +08:00
$(document).ready(function(){initNavTree('dc/d9a/group__quats.html','../../'); initResizable(); });
/* @license-end */
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< iframe src = "javascript:void(0)" frameborder = "0"
name="MSearchResults" id="MSearchResults">
< / iframe >
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#nested-classes" > Data Structures< / a > |
< a href = "#typedef-members" > Typedefs< / a > |
< a href = "#func-members" > Functions< / a > < / div >
2021-10-26 03:34:27 +08:00
< div class = "headertitle" > < div class = "title" > 3D Quaternion operations< div class = "ingroups" > < a class = "el" href = "../../de/d5a/group__quaternions.html" > Library for 3D Vectors & Quaternions< / a > < / div > < / div > < / div >
2020-08-27 03:28:38 +08:00
< / div > <!-- header -->
< div class = "contents" >
< div class = "dynheader" >
Collaboration diagram for 3D Quaternion operations:< / div >
< div class = "dyncontent" >
2021-12-10 01:57:52 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../dc/d9a/group__quats.svg" width = "380" height = "51" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe >
2020-08-27 03:28:38 +08:00
< / div >
< / div >
< table class = "memberdecls" >
2021-10-26 03:34:27 +08:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "nested-classes" name = "nested-classes" > < / a >
2020-08-27 03:28:38 +08:00
Data Structures< / h2 > < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > struct   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../de/d58/structquaternion__.html" > quaternion_< / a > < / td > < / tr >
< tr class = "memdesc:" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > a Quaternion type represented using a scalar \(w\) or \(q_0\) and a 3D vector \(\left(q_1,q_2,q_3\right)\) < a href = "../../de/d58/structquaternion__.html#details" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > struct   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d2/de8/structeuler__.html" > euler_< / a > < / td > < / tr >
< tr class = "memdesc:" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > 3D Euler or Tait-Bryan angles (in radian) < a href = "../../d2/de8/structeuler__.html#details" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
2021-10-26 03:34:27 +08:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "typedef-members" name = "typedef-members" > < / a >
2020-08-27 03:28:38 +08:00
Typedefs< / h2 > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "memitem:gaacd70a16b61dd47a19eb5fb729c2669b" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "gaacd70a16b61dd47a19eb5fb729c2669b" name = "gaacd70a16b61dd47a19eb5fb729c2669b" > < / a >
typedef struct < a class = "el" href = "../../de/d58/structquaternion__.html" > quaternion_< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < b > quaternion< / b > < / td > < / tr >
2020-08-27 03:28:38 +08:00
< tr class = "memdesc:gaacd70a16b61dd47a19eb5fb729c2669b" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > a Quaternion type represented using a scalar \(w\) or \(q_0\) and a 3D vector \(\left(q_1,q_2,q_3\right)\) < br / > < / td > < / tr >
< tr class = "separator:gaacd70a16b61dd47a19eb5fb729c2669b" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "memitem:ga8cc5e5b7a5fa492423ecf034c8bb52bd" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "ga8cc5e5b7a5fa492423ecf034c8bb52bd" name = "ga8cc5e5b7a5fa492423ecf034c8bb52bd" > < / a >
typedef struct < a class = "el" href = "../../d2/de8/structeuler__.html" > euler_< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < b > euler< / b > < / td > < / tr >
2020-08-27 03:28:38 +08:00
< tr class = "memdesc:ga8cc5e5b7a5fa492423ecf034c8bb52bd" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > 3D Euler or Tait-Bryan angles (in radian) < br / > < / td > < / tr >
< tr class = "separator:ga8cc5e5b7a5fa492423ecf034c8bb52bd" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
2021-10-26 03:34:27 +08:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
2020-08-27 03:28:38 +08:00
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:ga4779f448daaf806ce5e750c13b3e0965" > < td class = "memItemLeft" align = "right" valign = "top" > < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../dc/d9a/group__quats.html#ga4779f448daaf806ce5e750c13b3e0965" > quat_from_euler< / a > (const < a class = "el" href = "../../dc/d9a/group__quats.html#ga8cc5e5b7a5fa492423ecf034c8bb52bd" > euler< / a > *in_euler)< / td > < / tr >
< tr class = "memdesc:ga4779f448daaf806ce5e750c13b3e0965" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Function to convert given Euler angles to a quaternion. < a href = "../../dc/d9a/group__quats.html#ga4779f448daaf806ce5e750c13b3e0965" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:ga4779f448daaf806ce5e750c13b3e0965" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:ga1afd165100e9b02b86e3bd11b50f3b06" > < td class = "memItemLeft" align = "right" valign = "top" > < a class = "el" href = "../../dc/d9a/group__quats.html#ga8cc5e5b7a5fa492423ecf034c8bb52bd" > euler< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../dc/d9a/group__quats.html#ga1afd165100e9b02b86e3bd11b50f3b06" > euler_from_quat< / a > (const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *in_quat)< / td > < / tr >
< tr class = "memdesc:ga1afd165100e9b02b86e3bd11b50f3b06" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Function to convert given quaternion to Euler angles. < a href = "../../dc/d9a/group__quats.html#ga1afd165100e9b02b86e3bd11b50f3b06" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:ga1afd165100e9b02b86e3bd11b50f3b06" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:gaf5ad0f9c4f0facc5a9c3735a178156b1" > < td class = "memItemLeft" align = "right" valign = "top" > < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../dc/d9a/group__quats.html#gaf5ad0f9c4f0facc5a9c3735a178156b1" > quaternion_multiply< / a > (const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *in_quat1, const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *in_quat2)< / td > < / tr >
< tr class = "memdesc:gaf5ad0f9c4f0facc5a9c3735a178156b1" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Function to multiply two quaternions. < a href = "../../dc/d9a/group__quats.html#gaf5ad0f9c4f0facc5a9c3735a178156b1" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:gaf5ad0f9c4f0facc5a9c3735a178156b1" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 class = "groupheader" > Detailed Description< / h2 >
< h2 class = "groupheader" > Function Documentation< / h2 >
2021-10-26 03:34:27 +08:00
< a id = "ga1afd165100e9b02b86e3bd11b50f3b06" name = "ga1afd165100e9b02b86e3bd11b50f3b06" > < / a >
2020-08-27 03:28:38 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga1afd165100e9b02b86e3bd11b50f3b06" > ◆ < / a > < / span > euler_from_quat()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > < a class = "el" href = "../../dc/d9a/group__quats.html#ga8cc5e5b7a5fa492423ecf034c8bb52bd" > euler< / a > euler_from_quat < / td >
< td > (< / td >
< td class = "paramtype" > const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *  < / td >
< td class = "paramname" > < em > in_quat< / em > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Function to convert given quaternion to Euler angles. < / p >
< p class = "formulaDsp" >
2022-06-08 02:13:03 +08:00
\begin{eqnarray*}
\phi & = &
\tan^{-1}\left[\frac{2\left(q_0q_1+q_2q_3\right)}{1-2\left(q_1^2+q_2^2\right)}\right]\\
\theta & =
& -\sin^{-1}\left[2\left(q_0q_2-q_3q_1\right)\right]\\
\psi & = &
\tan^{-1}\left[\frac{2\left(q_0q_3+q_1q_2\right)}{1-2\left(q_2^2+q_3^2\right)}\right]\\
\end{eqnarray*}
2020-08-27 03:28:38 +08:00
< / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > in_quat< / td > < td > input quaternion instance < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > converted euler angles < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 89< / span > {< / div >
< div class = "line" > < span class = "lineno" > 90< / span > < a class = "code hl_struct" href = "../../d2/de8/structeuler__.html" > euler< / a > out_euler;< / div >
< div class = "line" > < span class = "lineno" > 91< / span > < span class = "keywordflow" > if< / span > (!in_quat) < span class = "comment" > // if null< / span > < / div >
< div class = "line" > < span class = "lineno" > 92< / span > {< / div >
< div class = "line" > < span class = "lineno" > 93< / span > fprintf(stderr, < span class = "stringliteral" > " %s: Invalid input." < / span > , __func__);< / div >
< div class = "line" > < span class = "lineno" > 94< / span > < span class = "keywordflow" > return< / span > out_euler;< / div >
< div class = "line" > < span class = "lineno" > 95< / span > }< / div >
< div class = "line" > < span class = "lineno" > 96< / span > < / div >
< div class = "line" > < span class = "lineno" > 97< / span > out_euler.< a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#a3f1b77e489be443a8d84a84082b8092e" > roll< / a > = atan2f(< / div >
< div class = "line" > < span class = "lineno" > 98< / span > 2.f * (in_quat-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat-> q1 + in_quat-> q2 * in_quat-> q3),< / div >
< div class = "line" > < span class = "lineno" > 99< / span > 1.f - 2.f * (in_quat-> q1 * in_quat-> q1 + in_quat-> q2 * in_quat-> q2));< / div >
< div class = "line" > < span class = "lineno" > 100< / span > out_euler.< a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aa71f9aa6dfa32d8014b2d54ab8410e0b" > pitch< / a > =< / div >
< div class = "line" > < span class = "lineno" > 101< / span > asinf(2.f * (in_quat-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat-> q2 + in_quat-> q1 * in_quat-> q3));< / div >
< div class = "line" > < span class = "lineno" > 102< / span > out_euler.< a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aad52507cc423ec49847471f6f15dd9d7" > yaw< / a > = atan2f(< / div >
< div class = "line" > < span class = "lineno" > 103< / span > 2.f * (in_quat-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat-> q3 + in_quat-> q1 * in_quat-> q2),< / div >
< div class = "line" > < span class = "lineno" > 104< / span > 1.f - 2.f * (in_quat-> q2 * in_quat-> q2 + in_quat-> q3 * in_quat-> q3));< / div >
< div class = "line" > < span class = "lineno" > 105< / span > < / div >
< div class = "line" > < span class = "lineno" > 106< / span > < span class = "keywordflow" > return< / span > out_euler;< / div >
< div class = "line" > < span class = "lineno" > 107< / span > }< / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "astructeuler___html" > < div class = "ttname" > < a href = "../../d2/de8/structeuler__.html" > euler_< / a > < / div > < div class = "ttdoc" > 3D Euler or Tait-Bryan angles (in radian)< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:81< / div > < / div >
< div class = "ttc" id = "astructeuler___html_a3f1b77e489be443a8d84a84082b8092e" > < div class = "ttname" > < a href = "../../d2/de8/structeuler__.html#a3f1b77e489be443a8d84a84082b8092e" > euler_::roll< / a > < / div > < div class = "ttdeci" > float roll< / div > < div class = "ttdoc" > or bank = rotation about X axis< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:84< / div > < / div >
< div class = "ttc" id = "astructeuler___html_aa71f9aa6dfa32d8014b2d54ab8410e0b" > < div class = "ttname" > < a href = "../../d2/de8/structeuler__.html#aa71f9aa6dfa32d8014b2d54ab8410e0b" > euler_::pitch< / a > < / div > < div class = "ttdeci" > float pitch< / div > < div class = "ttdoc" > or elevation = rotation about Y axis< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:89< / div > < / div >
< div class = "ttc" id = "astructeuler___html_aad52507cc423ec49847471f6f15dd9d7" > < div class = "ttname" > < a href = "../../d2/de8/structeuler__.html#aad52507cc423ec49847471f6f15dd9d7" > euler_::yaw< / a > < / div > < div class = "ttdeci" > float yaw< / div > < div class = "ttdoc" > or heading = rotation about Z axis< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:94< / div > < / div >
< div class = "ttc" id = "astructquaternion___html_a835e2ba72517fbb29d0d4e3cb4c2914f" > < div class = "ttname" > < a href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > quaternion_::w< / a > < / div > < div class = "ttdeci" > float w< / div > < div class = "ttdoc" > real part of quaternion< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:64< / div > < / div >
2020-08-27 03:28:38 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "ga4779f448daaf806ce5e750c13b3e0965" name = "ga4779f448daaf806ce5e750c13b3e0965" > < / a >
2020-08-27 03:28:38 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga4779f448daaf806ce5e750c13b3e0965" > ◆ < / a > < / span > quat_from_euler()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > quat_from_euler < / td >
< td > (< / td >
< td class = "paramtype" > const < a class = "el" href = "../../dc/d9a/group__quats.html#ga8cc5e5b7a5fa492423ecf034c8bb52bd" > euler< / a > *  < / td >
< td class = "paramname" > < em > in_euler< / em > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Function to convert given Euler angles to a quaternion. < / p >
< p class = "formulaDsp" >
2022-06-08 02:13:03 +08:00
\begin{eqnarray*}
q_{0} & =
& \cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)
+
\sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\
q_{1} & =
& \sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)
-
\cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\
q_{2} & =
& \cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)
+
\sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\
q_{3} & =
& \cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)
-
\sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)\\
\end{eqnarray*}
2020-08-27 03:28:38 +08:00
< / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > in_euler< / td > < td > input Euler angles instance < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > converted quaternion < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 48< / span > {< / div >
< div class = "line" > < span class = "lineno" > 49< / span > < a class = "code hl_struct" href = "../../de/d58/structquaternion__.html" > quaternion< / a > out_quat;< / div >
< div class = "line" > < span class = "lineno" > 50< / span > < / div >
< div class = "line" > < span class = "lineno" > 51< / span > < span class = "keywordflow" > if< / span > (!in_euler) < span class = "comment" > // if null< / span > < / div >
< div class = "line" > < span class = "lineno" > 52< / span > {< / div >
< div class = "line" > < span class = "lineno" > 53< / span > fprintf(stderr, < span class = "stringliteral" > " %s: Invalid input." < / span > , __func__);< / div >
< div class = "line" > < span class = "lineno" > 54< / span > < span class = "keywordflow" > return< / span > out_quat;< / div >
< div class = "line" > < span class = "lineno" > 55< / span > }< / div >
< div class = "line" > < span class = "lineno" > 56< / span > < / div >
< div class = "line" > < span class = "lineno" > 57< / span > < a class = "code hl_struct" href = "../../de/d58/structquaternion__.html" > quaternion< / a > temp;< / div >
< div class = "line" > < span class = "lineno" > 58< / span > < / div >
< div class = "line" > < span class = "lineno" > 59< / span > < span class = "keywordtype" > float< / span > cy = cosf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aad52507cc423ec49847471f6f15dd9d7" > yaw< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 60< / span > < span class = "keywordtype" > float< / span > sy = sinf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aad52507cc423ec49847471f6f15dd9d7" > yaw< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 61< / span > < span class = "keywordtype" > float< / span > cp = cosf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aa71f9aa6dfa32d8014b2d54ab8410e0b" > pitch< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 62< / span > < span class = "keywordtype" > float< / span > sp = sinf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#aa71f9aa6dfa32d8014b2d54ab8410e0b" > pitch< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 63< / span > < span class = "keywordtype" > float< / span > cr = cosf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#a3f1b77e489be443a8d84a84082b8092e" > roll< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 64< / span > < span class = "keywordtype" > float< / span > sr = sinf(in_euler-> < a class = "code hl_variable" href = "../../d2/de8/structeuler__.html#a3f1b77e489be443a8d84a84082b8092e" > roll< / a > * 0.5f);< / div >
< div class = "line" > < span class = "lineno" > 65< / span > < / div >
< div class = "line" > < span class = "lineno" > 66< / span > temp.w = cr * cp * cy + sr * sp * sy;< / div >
< div class = "line" > < span class = "lineno" > 67< / span > temp.q1 = sr * cp * cy - cr * sp * sy;< / div >
< div class = "line" > < span class = "lineno" > 68< / span > temp.q2 = cr * sp * cy + sr * cp * sy;< / div >
< div class = "line" > < span class = "lineno" > 69< / span > temp.q3 = cr * cp * sy - sr * sp * cy;< / div >
< div class = "line" > < span class = "lineno" > 70< / span > < / div >
< div class = "line" > < span class = "lineno" > 71< / span > < span class = "keywordflow" > return< / span > temp;< / div >
< div class = "line" > < span class = "lineno" > 72< / span > }< / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "astructquaternion___html" > < div class = "ttname" > < a href = "../../de/d58/structquaternion__.html" > quaternion_< / a > < / div > < div class = "ttdoc" > a Quaternion type represented using a scalar or and a 3D vector< / div > < div class = "ttdef" > < b > Definition:< / b > geometry_datatypes.h:61< / div > < / div >
2020-08-27 03:28:38 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "gaf5ad0f9c4f0facc5a9c3735a178156b1" name = "gaf5ad0f9c4f0facc5a9c3735a178156b1" > < / a >
2020-08-27 03:28:38 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gaf5ad0f9c4f0facc5a9c3735a178156b1" > ◆ < / a > < / span > quaternion_multiply()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > quaternion_multiply < / td >
< td > (< / td >
< td class = "paramtype" > const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *  < / td >
< td class = "paramname" > < em > in_quat1< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > const < a class = "el" href = "../../dc/d9a/group__quats.html#gaacd70a16b61dd47a19eb5fb729c2669b" > quaternion< / a > *  < / td >
< td class = "paramname" > < em > in_quat2< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Function to multiply two quaternions. < / p >
< p class = "formulaDsp" >
2022-06-08 02:13:03 +08:00
\begin{eqnarray*}
\mathbf{c} & = & \mathbf{a}\otimes\mathbf{b}\\
& = & \begin{bmatrix}a_{0} & a_{1} & a_{2} &
a_{3}\end{bmatrix}\otimes\begin{bmatrix}b_{0} & b_{1} & b_{2} &
b_{3}\end{bmatrix}\\
& = &
\begin{bmatrix}
a_{0}b_{0}-a_{1}b_{1}-a_{2}b_{2}-a_{3}b_{3}\\
a_{0}b_{1}+a_{1}b_{0}+a_{2}b_{3}-a_{3}b_{2}\\
a_{0}b_{2}-a_{1}b_{3}+a_{2}b_{0}+a_{3}b_{1}\\
a_{0}b_{3}+a_{1}b_{2}-a_{2}b_{1}+a_{3}b_{0}
\end{bmatrix}^{T}
\end{eqnarray*}
2020-08-27 03:28:38 +08:00
< / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > in_quat1< / td > < td > first input quaternion instance < / td > < / tr >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > in_quat2< / td > < td > second input quaternion instance < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > resultant quaternion < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 131< / span > {< / div >
< div class = "line" > < span class = "lineno" > 132< / span > < a class = "code hl_struct" href = "../../de/d58/structquaternion__.html" > quaternion< / a > out_quat;< / div >
< div class = "line" > < span class = "lineno" > 133< / span > < span class = "keywordflow" > if< / span > (!in_quat1 || !in_quat2) < span class = "comment" > // if null< / span > < / div >
< div class = "line" > < span class = "lineno" > 134< / span > {< / div >
< div class = "line" > < span class = "lineno" > 135< / span > fprintf(stderr, < span class = "stringliteral" > " %s: Invalid input." < / span > , __func__);< / div >
< div class = "line" > < span class = "lineno" > 136< / span > < span class = "keywordflow" > return< / span > out_quat;< / div >
< div class = "line" > < span class = "lineno" > 137< / span > }< / div >
< div class = "line" > < span class = "lineno" > 138< / span > < / div >
< div class = "line" > < span class = "lineno" > 139< / span > out_quat.< a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > = in_quat1-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat2-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > - in_quat1-> q1 * in_quat2-> q1 -< / div >
< div class = "line" > < span class = "lineno" > 140< / span > in_quat1-> q2 * in_quat2-> q2 - in_quat1-> q3 * in_quat2-> q3;< / div >
< div class = "line" > < span class = "lineno" > 141< / span > out_quat.q1 = in_quat1-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat2-> q1 + in_quat1-> q1 * in_quat2-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > +< / div >
< div class = "line" > < span class = "lineno" > 142< / span > in_quat1-> q2 * in_quat2-> q3 - in_quat1-> q3 * in_quat2-> q2;< / div >
< div class = "line" > < span class = "lineno" > 143< / span > out_quat.q2 = in_quat1-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat2-> q2 - in_quat1-> q1 * in_quat2-> q3 +< / div >
< div class = "line" > < span class = "lineno" > 144< / span > in_quat1-> q2 * in_quat2-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > + in_quat1-> q3 * in_quat2-> q1;< / div >
< div class = "line" > < span class = "lineno" > 145< / span > out_quat.q3 = in_quat1-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > * in_quat2-> q3 + in_quat1-> q1 * in_quat2-> q2 -< / div >
< div class = "line" > < span class = "lineno" > 146< / span > in_quat1-> q2 * in_quat2-> q1 + in_quat1-> q3 * in_quat2-> < a class = "code hl_variable" href = "../../de/d58/structquaternion__.html#a835e2ba72517fbb29d0d4e3cb4c2914f" > w< / a > ;< / div >
< div class = "line" > < span class = "lineno" > 147< / span > < / div >
< div class = "line" > < span class = "lineno" > 148< / span > < span class = "keywordflow" > return< / span > out_quat;< / div >
< div class = "line" > < span class = "lineno" > 149< / span > }< / div >
2020-08-27 03:28:38 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
2022-06-08 02:13:03 +08:00
< li class = "footer" > Generated by < a href = "https://www.doxygen.org/index.html" > < img class = "footer" src = "../../doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.9.4 < / li >
2020-08-27 03:28:38 +08:00
< / ul >
< / div >
< / body >
< / html >