ardupilot/libraries/doc/html/vector2_8h_source.html

196 lines
24 KiB
HTML
Raw Blame History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
<title>ArduPilot Libraries: /home/jgoppert/Projects/ap/libraries/AP_Math/vector2.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>/home/jgoppert/Projects/ap/libraries/AP_Math/vector2.h</h1> </div>
</div>
<div class="contents">
<a href="vector2_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-</span>
<a name="l00002"></a>00002
<a name="l00003"></a>00003 <span class="comment">// Copyright 2010 Michael Smith, all rights reserved.</span>
<a name="l00004"></a>00004
<a name="l00005"></a>00005 <span class="comment">// This library is free software; you can redistribute it and / or</span>
<a name="l00006"></a>00006 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00007"></a>00007 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00008"></a>00008 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="comment">// Derived closely from:</span>
<a name="l00011"></a>00011 <span class="comment">/****************************************</span>
<a name="l00012"></a>00012 <span class="comment"> * 2D Vector Classes</span>
<a name="l00013"></a>00013 <span class="comment"> * By Bill Perone (billperone@yahoo.com)</span>
<a name="l00014"></a>00014 <span class="comment"> * Original: 9-16-2002</span>
<a name="l00015"></a>00015 <span class="comment"> * Revised: 19-11-2003</span>
<a name="l00016"></a>00016 <span class="comment"> * 18-12-2003</span>
<a name="l00017"></a>00017 <span class="comment"> * 06-06-2004</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * <20> 2003, This code is provided &quot;as is&quot; and you can use it freely as long as</span>
<a name="l00020"></a>00020 <span class="comment"> * credit is given to Bill Perone in the application it is used in</span>
<a name="l00021"></a>00021 <span class="comment"> ****************************************/</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef VECTOR2_H</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define VECTOR2_H</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00029"></a><a class="code" href="struct_vector2.html">00029</a> <span class="keyword">struct </span><a class="code" href="struct_vector2.html">Vector2</a>
<a name="l00030"></a>00030 {
<a name="l00031"></a><a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">00031</a> T <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>, <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>;
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="comment">// trivial ctor</span>
<a name="l00034"></a>00034 <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a>() {memset(<span class="keyword">this</span>, 0, <span class="keyword">sizeof</span>(*<span class="keyword">this</span>));}
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="comment">// setting ctor</span>
<a name="l00037"></a>00037 <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a>(<span class="keyword">const</span> T x0, <span class="keyword">const</span> T y0): <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>(x0), <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>(y0) {}
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="comment">// function call operator</span>
<a name="l00040"></a><a class="code" href="struct_vector2.html#af58fdb320b592f2a623f767b96f82171">00040</a> <span class="keywordtype">void</span> <a class="code" href="struct_vector2.html#af58fdb320b592f2a623f767b96f82171">operator ()</a>(<span class="keyword">const</span> T x0, <span class="keyword">const</span> T y0)
<a name="l00041"></a>00041 { <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>= x0; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>= y0; }
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="comment">// test for equality</span>
<a name="l00044"></a><a class="code" href="struct_vector2.html#a90ace29e191da2edd698fe157c97c1cb">00044</a> <span class="keywordtype">bool</span> <a class="code" href="struct_vector2.html#a90ace29e191da2edd698fe157c97c1cb">operator==</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00045"></a>00045 { <span class="keywordflow">return</span> (<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>==v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a> &amp;&amp; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>==v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>); }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="comment">// test for inequality</span>
<a name="l00048"></a><a class="code" href="struct_vector2.html#aae7409be71fdf2f2680850c5d1075c59">00048</a> <span class="keywordtype">bool</span> <a class="code" href="struct_vector2.html#aae7409be71fdf2f2680850c5d1075c59">operator!=</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00049"></a>00049 { <span class="keywordflow">return</span> (<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>!=v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a> || <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>!=v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>); }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="comment">// negation</span>
<a name="l00052"></a><a class="code" href="struct_vector2.html#a339f9c13f2e01782181cc9eb1eaa72ab">00052</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a339f9c13f2e01782181cc9eb1eaa72ab">operator -</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00053"></a>00053 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a>(-<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>, -<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>); }
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="comment">// addition</span>
<a name="l00056"></a><a class="code" href="struct_vector2.html#a83a3ed475d346606e6617494aadd89d7">00056</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a83a3ed475d346606e6617494aadd89d7">operator +</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)<span class="keyword"> const</span>
<a name="l00057"></a>00057 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a>(<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>+v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>, <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>+v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>); }
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="comment">// subtraction</span>
<a name="l00060"></a><a class="code" href="struct_vector2.html#a7de0652ddb37d61ad2629c912edb0ec6">00060</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a339f9c13f2e01782181cc9eb1eaa72ab">operator -</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)<span class="keyword"> const</span>
<a name="l00061"></a>00061 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a>(<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>-v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>, <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>-v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>); }
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="comment">// uniform scaling</span>
<a name="l00064"></a><a class="code" href="struct_vector2.html#a518fc5ef42a00f68e65acce7c4e20bfa">00064</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a518fc5ef42a00f68e65acce7c4e20bfa">operator *</a>(<span class="keyword">const</span> T num)<span class="keyword"> const</span>
<a name="l00065"></a>00065 <span class="keyword"> </span>{
<a name="l00066"></a>00066 <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> temp(*<span class="keyword">this</span>);
<a name="l00067"></a>00067 <span class="keywordflow">return</span> temp*=num;
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="comment">// uniform scaling</span>
<a name="l00071"></a><a class="code" href="struct_vector2.html#ac68df7fdae361068c6af67be44668407">00071</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#ac68df7fdae361068c6af67be44668407">operator /</a>(<span class="keyword">const</span> T num)<span class="keyword"> const</span>
<a name="l00072"></a>00072 <span class="keyword"> </span>{
<a name="l00073"></a>00073 <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> temp(*<span class="keyword">this</span>);
<a name="l00074"></a>00074 <span class="keywordflow">return</span> temp/=num;
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="comment">// addition</span>
<a name="l00078"></a><a class="code" href="struct_vector2.html#a5c004e8ca8365c0a2c266654f234023e">00078</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;<a class="code" href="struct_vector2.html#a5c004e8ca8365c0a2c266654f234023e">operator +=</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>+=v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>+=v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>;
<a name="l00081"></a>00081 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="comment">// subtraction</span>
<a name="l00085"></a><a class="code" href="struct_vector2.html#a10ab47df2c0304ac442265f5d5d0b8a2">00085</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;<a class="code" href="struct_vector2.html#a10ab47df2c0304ac442265f5d5d0b8a2">operator -=</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087 <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>-=v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>-=v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>;
<a name="l00088"></a>00088 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="comment">// uniform scaling</span>
<a name="l00092"></a><a class="code" href="struct_vector2.html#a9ec8c1bae98c7bded59b4b80fa3e9dd5">00092</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;<a class="code" href="struct_vector2.html#a9ec8c1bae98c7bded59b4b80fa3e9dd5">operator *=</a>(<span class="keyword">const</span> T num)
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094 <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>*=num; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>*=num;
<a name="l00095"></a>00095 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="comment">// uniform scaling</span>
<a name="l00099"></a><a class="code" href="struct_vector2.html#a969b871f32a8f0d25bd569302028165c">00099</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;<a class="code" href="struct_vector2.html#a969b871f32a8f0d25bd569302028165c">operator /=</a>(<span class="keyword">const</span> T num)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>/=num; <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>/=num;
<a name="l00102"></a>00102 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <span class="comment">// dot product</span>
<a name="l00106"></a><a class="code" href="struct_vector2.html#a9e25e26dc47ede54ee2b49678aecdccf">00106</a> T <a class="code" href="struct_vector2.html#a518fc5ef42a00f68e65acce7c4e20bfa">operator *</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)<span class="keyword"> const</span>
<a name="l00107"></a>00107 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a>*v.<a class="code" href="struct_vector2.html#a78fa1f2ed5e261c7fbeb8f3536a1ee34">x</a> + <a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>*v.<a class="code" href="struct_vector2.html#a6cfed8355591aa269f4dba43bd806ef9">y</a>; }
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="comment">// gets the length of this vector squared</span>
<a name="l00110"></a><a class="code" href="struct_vector2.html#a0fd42927ade2df86b44ca09dca1d8314">00110</a> T <a class="code" href="struct_vector2.html#a0fd42927ade2df86b44ca09dca1d8314">length_squared</a>()<span class="keyword"> const</span>
<a name="l00111"></a>00111 <span class="keyword"> </span>{ <span class="keywordflow">return</span> (T)(*<span class="keyword">this</span> * *<span class="keyword">this</span>); }
<a name="l00112"></a>00112
<a name="l00113"></a>00113 <span class="comment">// gets the length of this vector</span>
<a name="l00114"></a><a class="code" href="struct_vector2.html#a119c51f16f90ffb3b30ee59475e7fdf8">00114</a> T <a class="code" href="struct_vector2.html#a119c51f16f90ffb3b30ee59475e7fdf8">length</a>()<span class="keyword"> const</span>
<a name="l00115"></a>00115 <span class="keyword"> </span>{ <span class="keywordflow">return</span> (T)sqrt(*<span class="keyword">this</span> * *<span class="keyword">this</span>); }
<a name="l00116"></a>00116
<a name="l00117"></a>00117 <span class="comment">// normalizes this vector</span>
<a name="l00118"></a><a class="code" href="struct_vector2.html#ace2a626eaa79412e2946216e9c3e63c6">00118</a> <span class="keywordtype">void</span> <a class="code" href="struct_vector2.html#ace2a626eaa79412e2946216e9c3e63c6">normalize</a>()
<a name="l00119"></a>00119 { *<span class="keyword">this</span>/=<a class="code" href="struct_vector2.html#a119c51f16f90ffb3b30ee59475e7fdf8">length</a>(); }
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="comment">// returns the normalized vector</span>
<a name="l00122"></a><a class="code" href="struct_vector2.html#a94313613241845651f3aba43ed9d5434">00122</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a94313613241845651f3aba43ed9d5434">normalized</a>()<span class="keyword"> const</span>
<a name="l00123"></a>00123 <span class="keyword"> </span>{ <span class="keywordflow">return</span> *<span class="keyword">this</span>/<a class="code" href="struct_vector2.html#a119c51f16f90ffb3b30ee59475e7fdf8">length</a>(); }
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="comment">// reflects this vector about n</span>
<a name="l00126"></a><a class="code" href="struct_vector2.html#ade6dd765f60fffb39e52cf117d043d97">00126</a> <span class="keywordtype">void</span> <a class="code" href="struct_vector2.html#ade6dd765f60fffb39e52cf117d043d97">reflect</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;n)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> orig(*<span class="keyword">this</span>);
<a name="l00129"></a>00129 <a class="code" href="struct_vector2.html#ae567d360aef8af212c7e3139cc22aff7">project</a>(n);
<a name="l00130"></a>00130 *<span class="keyword">this</span>= *<span class="keyword">this</span>*2 - orig;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="comment">// projects this vector onto v</span>
<a name="l00134"></a><a class="code" href="struct_vector2.html#ae567d360aef8af212c7e3139cc22aff7">00134</a> <span class="keywordtype">void</span> <a class="code" href="struct_vector2.html#ae567d360aef8af212c7e3139cc22aff7">project</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00135"></a>00135 { *<span class="keyword">this</span>= v * (*<span class="keyword">this</span> * v)/(v*v); }
<a name="l00136"></a>00136
<a name="l00137"></a>00137 <span class="comment">// returns this vector projected onto v</span>
<a name="l00138"></a><a class="code" href="struct_vector2.html#a3212191028319eb5d8b00cfd85068722">00138</a> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> <a class="code" href="struct_vector2.html#a3212191028319eb5d8b00cfd85068722">projected</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v)
<a name="l00139"></a>00139 { <span class="keywordflow">return</span> v * (*<span class="keyword">this</span> * v)/(v*v); }
<a name="l00140"></a>00140
<a name="l00141"></a>00141 <span class="comment">// computes the angle between 2 arbitrary vectors</span>
<a name="l00142"></a><a class="code" href="struct_vector2.html#a68370ff181ccbcc1731f531d4b813e84">00142</a> T <a class="code" href="struct_vector2.html#a68370ff181ccbcc1731f531d4b813e84">angle</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v1, <span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v2)
<a name="l00143"></a>00143 { <span class="keywordflow">return</span> (T)acosf((v1*v2) / (v1.<a class="code" href="struct_vector2.html#a119c51f16f90ffb3b30ee59475e7fdf8">length</a>()*v2.length())); }
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="comment">// computes the angle between 2 normalized arbitrary vectors</span>
<a name="l00146"></a><a class="code" href="struct_vector2.html#ab64d67cf7a2946580a234e8e327d1bc3">00146</a> T <a class="code" href="struct_vector2.html#ab64d67cf7a2946580a234e8e327d1bc3">angle_normalized</a>(<span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v1, <span class="keyword">const</span> <a class="code" href="struct_vector2.html">Vector2&lt;T&gt;</a> &amp;v2)
<a name="l00147"></a>00147 { <span class="keywordflow">return</span> (T)acosf(v1*v2); }
<a name="l00148"></a>00148
<a name="l00149"></a>00149 };
<a name="l00150"></a>00150
<a name="l00151"></a><a class="code" href="vector2_8h.html#aa83d444bd6cbecb112158663c2e0c213">00151</a> <span class="keyword">typedef</span> <a class="code" href="struct_vector2.html">Vector2&lt;int&gt;</a> <a class="code" href="struct_vector2.html">Vector2i</a>;
<a name="l00152"></a><a class="code" href="vector2_8h.html#a67842bda415130ff792b0e0f40899e50">00152</a> <span class="keyword">typedef</span> <a class="code" href="struct_vector2.html">Vector2&lt;unsigned int&gt;</a> <a class="code" href="struct_vector2.html">Vector2ui</a>;
<a name="l00153"></a><a class="code" href="vector2_8h.html#af582ca987c4b5834434eac69cbbc5f68">00153</a> <span class="keyword">typedef</span> <a class="code" href="struct_vector2.html">Vector2&lt;long&gt;</a> <a class="code" href="struct_vector2.html">Vector2l</a>;
<a name="l00154"></a><a class="code" href="vector2_8h.html#a0f0a8b46227cdb465d2f73d57281c972">00154</a> <span class="keyword">typedef</span> <a class="code" href="struct_vector2.html">Vector2&lt;unsigned long&gt;</a> <a class="code" href="struct_vector2.html">Vector2ul</a>;
<a name="l00155"></a><a class="code" href="vector2_8h.html#a9f3739462b0605dcb64299fa289b6afe">00155</a> <span class="keyword">typedef</span> <a class="code" href="struct_vector2.html">Vector2&lt;float&gt;</a> <a class="code" href="struct_vector2.html">Vector2f</a>;
<a name="l00156"></a>00156
<a name="l00157"></a>00157 <span class="preprocessor">#endif // VECTOR2_H</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated for ArduPilot Libraries by&nbsp;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a></small></address>
</body>
</html>