TheAlgorithms-C/de/d7b/group__vec__3d.html
2021-10-25 19:34:27 +00:00

621 lines
48 KiB
HTML

<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: 3D Vector 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">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</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>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<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">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('de/d7b/group__vec__3d.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> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">3D Vector operations<div class="ingroups"><a class="el" href="../../de/d5a/group__quaternions.html">Library for 3D Vectors &amp; Quaternions</a></div></div></div>
</div><!--header-->
<div class="contents">
<div class="dynheader">
Collaboration diagram for 3D Vector operations:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d7b/group__vec__3d.svg" width="356" height="51"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/db4/structvec__3d__.html">vec_3d_</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">3D vector type <a href="../../d5/db4/structvec__3d__.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gaf9ee870d4922e488bdd3e7262485c270"><td class="memItemLeft" align="right" valign="top"><a id="gaf9ee870d4922e488bdd3e7262485c270" name="gaf9ee870d4922e488bdd3e7262485c270"></a>
typedef struct <a class="el" href="../../d5/db4/structvec__3d__.html">vec_3d_</a>&#160;</td><td class="memItemRight" valign="bottom"><b>vec_3d</b></td></tr>
<tr class="memdesc:gaf9ee870d4922e488bdd3e7262485c270"><td class="mdescLeft">&#160;</td><td class="mdescRight">3D vector type <br /></td></tr>
<tr class="separator:gaf9ee870d4922e488bdd3e7262485c270"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga97da356cb7d5da73a0ac9bad09a435cc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga97da356cb7d5da73a0ac9bad09a435cc">vector_sub</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *b)</td></tr>
<tr class="memdesc:ga97da356cb7d5da73a0ac9bad09a435cc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subtract one vector from another. <a href="../../de/d7b/group__vec__3d.html#ga97da356cb7d5da73a0ac9bad09a435cc">More...</a><br /></td></tr>
<tr class="separator:ga97da356cb7d5da73a0ac9bad09a435cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa6b5ac18429ffb0131dc8593d31c25a4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#gaa6b5ac18429ffb0131dc8593d31c25a4">vector_add</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *b)</td></tr>
<tr class="memdesc:gaa6b5ac18429ffb0131dc8593d31c25a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Add one vector to another. <a href="../../de/d7b/group__vec__3d.html#gaa6b5ac18429ffb0131dc8593d31c25a4">More...</a><br /></td></tr>
<tr class="separator:gaa6b5ac18429ffb0131dc8593d31c25a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga243e74d542d0d4d14fa3ae0bc2170d84"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">dot_prod</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *b)</td></tr>
<tr class="memdesc:ga243e74d542d0d4d14fa3ae0bc2170d84"><td class="mdescLeft">&#160;</td><td class="mdescRight">Obtain the dot product of two 3D vectors. <a href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">More...</a><br /></td></tr>
<tr class="separator:ga243e74d542d0d4d14fa3ae0bc2170d84"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae4a49e6bdf13df949e8b23c7925bb5f5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#gae4a49e6bdf13df949e8b23c7925bb5f5">vector_prod</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *b)</td></tr>
<tr class="memdesc:gae4a49e6bdf13df949e8b23c7925bb5f5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the vector product of two 3d vectors. <a href="../../de/d7b/group__vec__3d.html#gae4a49e6bdf13df949e8b23c7925bb5f5">More...</a><br /></td></tr>
<tr class="separator:gae4a49e6bdf13df949e8b23c7925bb5f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae25e1f2e973933bef65838601e2de0af"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#gae25e1f2e973933bef65838601e2de0af">print_vector</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const char *name)</td></tr>
<tr class="memdesc:gae25e1f2e973933bef65838601e2de0af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Print formatted vector on stdout. <a href="../../de/d7b/group__vec__3d.html#gae25e1f2e973933bef65838601e2de0af">More...</a><br /></td></tr>
<tr class="separator:gae25e1f2e973933bef65838601e2de0af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga94805165d037d111d7d7c0df99e3a5de"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a)</td></tr>
<tr class="memdesc:ga94805165d037d111d7d7c0df99e3a5de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the norm a vector. <a href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">More...</a><br /></td></tr>
<tr class="separator:ga94805165d037d111d7d7c0df99e3a5de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3cdfd8378a0b115563ea6c561bb46b7e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga3cdfd8378a0b115563ea6c561bb46b7e">unit_vec</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a)</td></tr>
<tr class="memdesc:ga3cdfd8378a0b115563ea6c561bb46b7e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Obtain unit vector in the same direction as given vector. <a href="../../de/d7b/group__vec__3d.html#ga3cdfd8378a0b115563ea6c561bb46b7e">More...</a><br /></td></tr>
<tr class="separator:ga3cdfd8378a0b115563ea6c561bb46b7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5082b0720c2cc51ae84bf19bd76dc849"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../dd/d7a/group__matrix.html#ga9f844010cb96591fa94c9d533a500ab7">mat_3x3</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga5082b0720c2cc51ae84bf19bd76dc849">get_cross_matrix</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a)</td></tr>
<tr class="memdesc:ga5082b0720c2cc51ae84bf19bd76dc849"><td class="mdescLeft">&#160;</td><td class="mdescRight">The cross product of vectors can be represented as a matrix multiplication operation. <a href="../../de/d7b/group__vec__3d.html#ga5082b0720c2cc51ae84bf19bd76dc849">More...</a><br /></td></tr>
<tr class="separator:ga5082b0720c2cc51ae84bf19bd76dc849"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga55be1d766c8a824b35d97e79744834d8"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#ga55be1d766c8a824b35d97e79744834d8">get_angle</a> (const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *a, const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *b)</td></tr>
<tr class="memdesc:ga55be1d766c8a824b35d97e79744834d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Obtain the angle between two given vectors. <a href="../../de/d7b/group__vec__3d.html#ga55be1d766c8a824b35d97e79744834d8">More...</a><br /></td></tr>
<tr class="separator:ga55be1d766c8a824b35d97e79744834d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga243e74d542d0d4d14fa3ae0bc2170d84" name="ga243e74d542d0d4d14fa3ae0bc2170d84"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga243e74d542d0d4d14fa3ae0bc2170d84">&#9670;&nbsp;</a></span>dot_prod()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">float dot_prod </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Obtain the dot product of two 3D vectors. </p>
<p class="formulaDsp">
\[ \vec{a}\cdot\vec{b}=a_xb_x + a_yb_y + a_zb_z \]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>first vector </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>second vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>resulting dot product </dd></dl>
<div class="fragment"><div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span>{</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="keywordtype">float</span> dot;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span><span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> arm_dot_prod_f32((<span class="keywordtype">float</span> *)a, (<span class="keywordtype">float</span> *)b, &amp;dot);</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> dot = a-&gt;x * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> dot += a-&gt;y * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a>;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> dot += a-&gt;z * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a>;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keywordflow">return</span> dot;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span>}</div>
<div class="ttc" id="astructvec__3d___html_a3339a40de7385fa55bee30be81c098c6"><div class="ttname"><a href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">vec_3d_::z</a></div><div class="ttdeci">float z</div><div class="ttdoc">Z co-ordinate.</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:25</div></div>
<div class="ttc" id="astructvec__3d___html_a53462a5a195c9e16fb584f73fd66c3d0"><div class="ttname"><a href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">vec_3d_::x</a></div><div class="ttdeci">float x</div><div class="ttdoc">X co-ordinate.</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:23</div></div>
<div class="ttc" id="astructvec__3d___html_a76098d39a382838df3b4b48c3443413b"><div class="ttname"><a href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">vec_3d_::y</a></div><div class="ttdeci">float y</div><div class="ttdoc">Y co-ordinate.</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:24</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ga55be1d766c8a824b35d97e79744834d8" name="ga55be1d766c8a824b35d97e79744834d8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga55be1d766c8a824b35d97e79744834d8">&#9670;&nbsp;</a></span>get_angle()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">double get_angle </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Obtain the angle between two given vectors. </p>
<p class="formulaDsp">
\[\alpha=acos\left(\frac{\vec{a} \cdot \vec{b}}{\lVert\vec{a}\rVert \cdot \lVert\vec{b}\rVert}\right)\]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>first input vector </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>second input vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>angle between \(\vec{a}\) and \(\vec{b}\) in radians </dd></dl>
<p >&lt; The norm of vector a</p>
<p >&lt; The norm of vector b</p>
<p >detect possible division by 0 - the angle is not defined in this case</p>
<div class="fragment"><div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span>{</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> <span class="keywordtype">double</span> alpha, cos_alpha;</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> <span class="keywordtype">float</span> norm_a = <a class="code hl_function" href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a>(a); <span class="comment">///&lt; The norm of vector a</span></div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> <span class="keywordtype">float</span> norm_b = <a class="code hl_function" href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a>(b); <span class="comment">///&lt; The norm of vector b</span></div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</span> <span class="keywordflow">if</span> (fabsf(norm_a) &lt; <a class="code hl_define" href="../../de/d5a/group__quaternions.html#ga002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> || fabsf(norm_b) &lt; <a class="code hl_define" href="../../de/d5a/group__quaternions.html#ga002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>) <span class="comment">/// detect possible division by 0 - the angle is not defined in this case</span></div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> { </div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <span class="keywordflow">return</span> NAN; </div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> }</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> </div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> cos_alpha = <a class="code hl_function" href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">dot_prod</a>(a, b) / (norm_a * norm_b);</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> alpha = acos(cos_alpha); <span class="comment">// delivers the radian</span></div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> <span class="keywordflow">return</span> alpha; <span class="comment">// in range from -1 to 1</span></div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span>}</div>
<div class="ttc" id="agroup__quaternions_html_ga002b2f4894492820fe708b1b7e7c5e70"><div class="ttname"><a href="../../de/d5a/group__quaternions.html#ga002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div><div class="ttdeci">#define EPSILON</div><div class="ttdoc">Minimum recognizable value.</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:14</div></div>
<div class="ttc" id="agroup__vec__3d_html_ga243e74d542d0d4d14fa3ae0bc2170d84"><div class="ttname"><a href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">dot_prod</a></div><div class="ttdeci">float dot_prod(const vec_3d *a, const vec_3d *b)</div><div class="ttdoc">Obtain the dot product of two 3D vectors.</div><div class="ttdef"><b>Definition:</b> vectors_3d.c:76</div></div>
<div class="ttc" id="agroup__vec__3d_html_ga94805165d037d111d7d7c0df99e3a5de"><div class="ttname"><a href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a></div><div class="ttdeci">float vector_norm(const vec_3d *a)</div><div class="ttdoc">Compute the norm a vector.</div><div class="ttdef"><b>Definition:</b> vectors_3d.c:138</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d7b/group__vec__3d_ga55be1d766c8a824b35d97e79744834d8_cgraph.svg" width="358" height="63"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ga5082b0720c2cc51ae84bf19bd76dc849" name="ga5082b0720c2cc51ae84bf19bd76dc849"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5082b0720c2cc51ae84bf19bd76dc849">&#9670;&nbsp;</a></span>get_cross_matrix()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../dd/d7a/group__matrix.html#ga9f844010cb96591fa94c9d533a500ab7">mat_3x3</a> get_cross_matrix </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The cross product of vectors can be represented as a matrix multiplication operation. </p>
<p >This function obtains the <code>3x3</code> matrix of the cross-product operator from the first vector. </p><p class="formulaDsp">
\[\begin{align*} \left(\vec{a}\times\right)\vec{b} &amp;= \tilde{A}_a\vec{b}\\ \tilde{A}_a &amp;= \begin{bmatrix}0&amp;-a_z&amp;a_y\\a_z&amp;0&amp;-a_x\\-a_y&amp;a_x&amp;0\end{bmatrix} \end{align*}\]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>input vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the <code>3x3</code> matrix for the cross product operator \(\left(\vec{a}\times\right)\) </dd></dl>
<div class="fragment"><div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span>{</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> <a class="code hl_struct" href="../../d9/d8b/structmat__3x3__.html">mat_3x3</a> A = {0., -a-&gt;z, a-&gt;y, a-&gt;z, 0., -a-&gt;x, -a-&gt;y, a-&gt;x, 0.};</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> <span class="keywordflow">return</span> A;</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span>}</div>
<div class="ttc" id="astructmat__3x3___html"><div class="ttname"><a href="../../d9/d8b/structmat__3x3__.html">mat_3x3_</a></div><div class="ttdoc">A 3x3 Matrix type definition.</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:35</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="gae25e1f2e973933bef65838601e2de0af" name="gae25e1f2e973933bef65838601e2de0af"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae25e1f2e973933bef65838601e2de0af">&#9670;&nbsp;</a></span>print_vector()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char * print_vector </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>name</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Print formatted vector on stdout. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>vector to print </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">name</td><td>name of the vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>string representation of vector </dd></dl>
<div class="fragment"><div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span>{</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="keyword">static</span> <span class="keywordtype">char</span> vec_str[100]; <span class="comment">// static to ensure the string life extends the</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="comment">// life of function</span></div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> </div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> snprintf(vec_str, 99, <span class="stringliteral">&quot;vec(%s) = (%.3g)i + (%.3g)j + (%.3g)k\n&quot;</span>, name, a-&gt;x,</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> a-&gt;y, a-&gt;z);</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keywordflow">return</span> vec_str;</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ga3cdfd8378a0b115563ea6c561bb46b7e" name="ga3cdfd8378a0b115563ea6c561bb46b7e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3cdfd8378a0b115563ea6c561bb46b7e">&#9670;&nbsp;</a></span>unit_vec()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> unit_vec </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Obtain unit vector in the same direction as given vector. </p>
<p class="formulaDsp">
\[\hat{a}=\frac{\vec{a}}{\lVert\vec{a}\rVert}\]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>input vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>n unit vector in the direction of \(\vec{a}\) </dd></dl>
<div class="fragment"><div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span>{</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <a class="code hl_struct" href="../../d5/db4/structvec__3d__.html">vec_3d</a> n = {0};</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> </div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <span class="keywordtype">float</span> norm = <a class="code hl_function" href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a>(a);</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <span class="keywordflow">if</span> (fabsf(norm) &lt; <a class="code hl_define" href="../../de/d5a/group__quaternions.html#ga002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>)</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> { <span class="comment">// detect possible divide by 0</span></div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <span class="keywordflow">return</span> n;</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> }</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> </div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="keywordflow">if</span> (norm != 1.F) <span class="comment">// perform division only if needed</span></div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> {</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> n.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x / norm;</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> n.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y / norm;</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> n.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z / norm;</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> }</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <span class="keywordflow">return</span> n;</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span>}</div>
<div class="ttc" id="astructvec__3d___html"><div class="ttname"><a href="../../d5/db4/structvec__3d__.html">vec_3d_</a></div><div class="ttdoc">3D vector type</div><div class="ttdef"><b>Definition:</b> geometry_datatypes.h:22</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d7b/group__vec__3d_ga3cdfd8378a0b115563ea6c561bb46b7e_cgraph.svg" width="350" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="gaa6b5ac18429ffb0131dc8593d31c25a4" name="gaa6b5ac18429ffb0131dc8593d31c25a4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa6b5ac18429ffb0131dc8593d31c25a4">&#9670;&nbsp;</a></span>vector_add()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> vector_add </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Add one vector to another. </p>
<p class="formulaDsp">
\[ \vec{c}=\vec{a}+\vec{b}=\left(a_x+b_x\right)\hat{i}+ \left(a_y+b_y\right)\hat{j}+\left(a_z+b_z\right)\hat{k}\]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>vector to add to </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>vector to add </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>resultant vector </dd></dl>
<div class="fragment"><div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span>{</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_struct" href="../../d5/db4/structvec__3d__.html">vec_3d</a> out;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span><span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> arm_add_f32((<span class="keywordtype">float</span> *)a, (<span class="keywordtype">float</span> *)b, (<span class="keywordtype">float</span> *)&amp;out);</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x + b-&gt;x;</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y + b-&gt;y;</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z + b-&gt;z;</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="keywordflow">return</span> out;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ga94805165d037d111d7d7c0df99e3a5de" name="ga94805165d037d111d7d7c0df99e3a5de"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga94805165d037d111d7d7c0df99e3a5de">&#9670;&nbsp;</a></span>vector_norm()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">float vector_norm </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the norm a vector. </p>
<p class="formulaDsp">
\[\lVert\vec{a}\rVert = \sqrt{\vec{a}\cdot\vec{a}} \]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>input vector </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>norm of the given vector </dd></dl>
<div class="fragment"><div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span>{</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> <span class="keywordtype">float</span> n = <a class="code hl_function" href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">dot_prod</a>(a, a);</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span><span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> arm_sqrt_f32(*n, n);</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> n = sqrtf(n);</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> </div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <span class="keywordflow">return</span> n;</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d7b/group__vec__3d_ga94805165d037d111d7d7c0df99e3a5de_cgraph.svg" width="230" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="gae4a49e6bdf13df949e8b23c7925bb5f5" name="gae4a49e6bdf13df949e8b23c7925bb5f5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae4a49e6bdf13df949e8b23c7925bb5f5">&#9670;&nbsp;</a></span>vector_prod()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> vector_prod </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the vector product of two 3d vectors. </p>
<p class="formulaDsp">
\[\begin{align*} \vec{a}\times\vec{b} &amp;= \begin{vmatrix} \hat{i} &amp; \hat{j} &amp; \hat{k}\\ a_x &amp; a_y &amp; a_z\\ b_x &amp; b_y &amp; b_z \end{vmatrix}\\ &amp;= \left(a_yb_z-b_ya_z\right)\hat{i} - \left(a_xb_z-b_xa_z\right)\hat{j} + \left(a_xb_y-b_xa_y\right)\hat{k} \end{align*} \]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>first vector \(\vec{a}\) </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>second vector \(\vec{b}\) </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>resultant vector \(\vec{o}=\vec{a}\times\vec{b}\) </dd></dl>
<div class="fragment"><div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span>{</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <a class="code hl_struct" href="../../d5/db4/structvec__3d__.html">vec_3d</a> out; <span class="comment">// better this way to avoid copying results to input</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> <span class="comment">// vectors themselves</span></div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;y * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> - a-&gt;z * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a>;</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = -a-&gt;x * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> + a-&gt;z * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;x * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> - a-&gt;y * b-&gt;<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keywordflow">return</span> out;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ga97da356cb7d5da73a0ac9bad09a435cc" name="ga97da356cb7d5da73a0ac9bad09a435cc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga97da356cb7d5da73a0ac9bad09a435cc">&#9670;&nbsp;</a></span>vector_sub()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> vector_sub </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a> *&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Subtract one vector from another. </p>
<p class="formulaDsp">
\[ \vec{c}=\vec{a}-\vec{b}=\left(a_x-b_x\right)\hat{i}+ \left(a_y-b_y\right)\hat{j}+\left(a_z-b_z\right)\hat{k}\]
</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>vector to subtract from </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>vector to subtract </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>resultant vector </dd></dl>
<div class="fragment"><div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span>{</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <a class="code hl_struct" href="../../d5/db4/structvec__3d__.html">vec_3d</a> out;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> arm_sub_f32((<span class="keywordtype">float</span> *)a, (<span class="keywordtype">float</span> *)b, (<span class="keywordtype">float</span> *)&amp;out);</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x - b-&gt;x;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y - b-&gt;y;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> out.<a class="code hl_variable" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z - b-&gt;z;</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="keywordflow">return</span> out;</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span>}</div>
</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>
<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.2 </li>
</ul>
</div>
</body>
</html>