TheAlgorithms-C/de/d7b/group__vec__3d.html
2020-09-03 12:54:15 +00:00

556 lines
41 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=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<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
&#160;<span id="projectnumber">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.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(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="355" 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 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 name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gaf9ee870d4922e488bdd3e7262485c270"><td class="memItemLeft" align="right" valign="top"><a id="gaf9ee870d4922e488bdd3e7262485c270"></a>
typedef struct <a class="el" href="../../d5/db4/structvec__3d__.html">vec_3d_</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/d7b/group__vec__3d.html#gaf9ee870d4922e488bdd3e7262485c270">vec_3d</a></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 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:ga4fd194972bea4884e0b33cf4a166d14e"><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#ga4fd194972bea4884e0b33cf4a166d14e">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:ga4fd194972bea4884e0b33cf4a166d14e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Print formatted vector on stdout. <a href="../../de/d7b/group__vec__3d.html#ga4fd194972bea4884e0b33cf4a166d14e">More...</a><br /></td></tr>
<tr class="separator:ga4fd194972bea4884e0b33cf4a166d14e"><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>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Function Documentation</h2>
<a id="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 name="l00077"></a><span class="lineno"> 77</span>&#160;{</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="keywordtype">float</span> dot;</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;<span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; arm_dot_prod_f32((<span class="keywordtype">float</span> *)a, (<span class="keywordtype">float</span> *)b, &amp;dot);</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; dot = a-&gt;x * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; dot += a-&gt;y * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a>;</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; dot += a-&gt;z * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a>;</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <span class="keywordflow">return</span> dot;</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="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 name="l00189"></a><span class="lineno"> 189</span>&#160;{</div>
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160; <a class="code" 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 name="l00191"></a><span class="lineno"> 191</span>&#160; <span class="keywordflow">return</span> A;</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ga4fd194972bea4884e0b33cf4a166d14e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4fd194972bea4884e0b33cf4a166d14e">&#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 name="l00123"></a><span class="lineno"> 123</span>&#160;{</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; <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 name="l00125"></a><span class="lineno"> 125</span>&#160; <span class="comment">// life of function</span></div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; </div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; 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 name="l00128"></a><span class="lineno"> 128</span>&#160; a-&gt;y, a-&gt;z);</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keywordflow">return</span> vec_str;</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="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 name="l00157"></a><span class="lineno"> 157</span>&#160;{</div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; <a class="code" href="../../d5/db4/structvec__3d__.html">vec_3d</a> n = {0};</div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160; </div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; <span class="keywordtype">float</span> norm = <a class="code" href="../../de/d7b/group__vec__3d.html#ga94805165d037d111d7d7c0df99e3a5de">vector_norm</a>(a);</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; <span class="keywordflow">if</span> (fabsf(norm) &lt; <a class="code" href="../../de/d5a/group__quaternions.html#ga002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>)</div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; { <span class="comment">// detect possible divide by 0</span></div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; <span class="keywordflow">return</span> n;</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; }</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; </div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; <span class="keywordflow">if</span> (norm != 1.F) <span class="comment">// perform division only if needed</span></div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; {</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; n.<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x / norm;</div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; n.<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y / norm;</div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; n.<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z / norm;</div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; }</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; <span class="keywordflow">return</span> n;</div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160;}</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="344" 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"></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 name="l00054"></a><span class="lineno"> 54</span>&#160;{</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <a class="code" href="../../d5/db4/structvec__3d__.html">vec_3d</a> out;</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; 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 name="l00058"></a><span class="lineno"> 58</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x + b-&gt;x;</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y + b-&gt;y;</div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z + b-&gt;z;</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="keywordflow">return</span> out;</div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="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 name="l00139"></a><span class="lineno"> 139</span>&#160;{</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <span class="keywordtype">float</span> n = <a class="code" href="../../de/d7b/group__vec__3d.html#ga243e74d542d0d4d14fa3ae0bc2170d84">dot_prod</a>(a, a);</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160;<span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; arm_sqrt_f32(*n, n);</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; n = sqrtf(n);</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; </div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; <span class="keywordflow">return</span> n;</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160;}</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="226" 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"></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 name="l00106"></a><span class="lineno"> 106</span>&#160;{</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160; <a class="code" 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 name="l00108"></a><span class="lineno"> 108</span>&#160; <span class="comment">// vectors themselves</span></div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;y * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> - a-&gt;z * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a>;</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = -a-&gt;x * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> + a-&gt;z * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;x * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> - a-&gt;y * b-&gt;<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a>;</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; </div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; <span class="keywordflow">return</span> out;</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="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 name="l00032"></a><span class="lineno"> 32</span>&#160;{</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <a class="code" href="../../d5/db4/structvec__3d__.html">vec_3d</a> out;</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160;<span class="preprocessor">#ifdef LIBQUAT_ARM</span></div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; 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 name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a53462a5a195c9e16fb584f73fd66c3d0">x</a> = a-&gt;x - b-&gt;x;</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a76098d39a382838df3b4b48c3443413b">y</a> = a-&gt;y - b-&gt;y;</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; out.<a class="code" href="../../d5/db4/structvec__3d__.html#a3339a40de7385fa55bee30be81c098c6">z</a> = a-&gt;z - b-&gt;z;</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; <span class="keywordflow">return</span> out;</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<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="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="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 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 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="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="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 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>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="http://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20 </li>
</ul>
</div>
</body>
</html>