2010-12-26 20:59:17 -04:00
<!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/vector3.h Source File< / title >
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
2010-12-26 23:23:35 -04:00
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javaScript" src = "search/search.js" > < / script >
2010-12-26 20:59:17 -04:00
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
2010-12-26 23:23:35 -04:00
< body onload = 'searchBox.OnSelectItem(0);' >
2010-12-26 20:59:17 -04:00
<!-- Generated by Doxygen 1.7.1 -->
< div class = "navigation" id = "top" >
< div class = "tabs" >
< ul class = "tablist" >
< li > < a href = "main.html" > < span > Main 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 List< / span > < / a > < / li >
< li > < a href = "globals.html" > < span > File Members< / span > < / a > < / li >
< / ul >
< / div >
< div class = "header" >
< div class = "headertitle" >
< h1 > /home/jgoppert/Projects/ap/libraries/AP_Math/vector3.h< / h1 > < / div >
< / div >
< div class = "contents" >
< a href = "vector3_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" > * 3D 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" > * 11-12-2003< / span >
< a name = "l00017" > < / a > 00017 < span class = "comment" > * 18-12-2003< / span >
< a name = "l00018" > < / a > 00018 < span class = "comment" > * 06-06-2004< / span >
< a name = "l00019" > < / a > 00019 < span class = "comment" > *< / span >
< a name = "l00020" > < / a > 00020 < span class = "comment" > * <20> 2003, This code is provided " as is" and you can use it freely as long as< / span >
< a name = "l00021" > < / a > 00021 < span class = "comment" > * credit is given to Bill Perone in the application it is used in< / span >
< a name = "l00022" > < / a > 00022 < span class = "comment" > *< / span >
< a name = "l00023" > < / a > 00023 < span class = "comment" > * Notes:< / span >
< a name = "l00024" > < / a > 00024 < span class = "comment" > * if a*b = 0 then a & b are orthogonal< / span >
< a name = "l00025" > < / a > 00025 < span class = "comment" > * a%b = -b%a< / span >
< a name = "l00026" > < / a > 00026 < span class = "comment" > * a*(b%c) = (a%b)*c< / span >
< a name = "l00027" > < / a > 00027 < span class = "comment" > * a%b = a(cast to matrix)*b< / span >
< a name = "l00028" > < / a > 00028 < span class = "comment" > * (a%b).length() = area of parallelogram formed by a & b< / span >
< a name = "l00029" > < / a > 00029 < span class = "comment" > * (a%b).length() = a.length()*b.length() * sin(angle between a & b)< / span >
< a name = "l00030" > < / a > 00030 < span class = "comment" > * (a%b).length() = 0 if angle between a & b = 0 or a.length() = 0 or b.length() = 0< / span >
< a name = "l00031" > < / a > 00031 < span class = "comment" > * a * (b%c) = volume of parallelpiped formed by a, b, c< / span >
< a name = "l00032" > < / a > 00032 < span class = "comment" > * vector triple product: a%(b%c) = b*(a*c) - c*(a*b)< / span >
< a name = "l00033" > < / a > 00033 < span class = "comment" > * scalar triple product: a*(b%c) = c*(a%b) = b*(c%a)< / span >
< a name = "l00034" > < / a > 00034 < span class = "comment" > * vector quadruple product: (a%b)*(c%d) = (a*c)*(b*d) - (a*d)*(b*c)< / span >
< a name = "l00035" > < / a > 00035 < span class = "comment" > * if a is unit vector along b then a%b = -b%a = -b(cast to matrix)*a = 0< / span >
< a name = "l00036" > < / a > 00036 < span class = "comment" > * vectors a1...an are linearly dependant if there exists a vector of scalars (b) where a1*b1 + ... + an*bn = 0< / span >
< a name = "l00037" > < / a > 00037 < span class = "comment" > * or if the matrix (A) * b = 0< / span >
< a name = "l00038" > < / a > 00038 < span class = "comment" > *< / span >
< a name = "l00039" > < / a > 00039 < span class = "comment" > ****************************************/< / span >
< a name = "l00040" > < / a > 00040
< a name = "l00041" > < / a > 00041 < span class = "preprocessor" > #ifndef VECTOR3_H< / span >
< a name = "l00042" > < / a > 00042 < span class = "preprocessor" > < / span > < span class = "preprocessor" > #define VECTOR3_H< / span >
< a name = "l00043" > < / a > 00043 < span class = "preprocessor" > < / span >
< a name = "l00044" > < / a > 00044 < span class = "preprocessor" > #include < math.h> < / span >
< a name = "l00045" > < / a > 00045 < span class = "preprocessor" > #include < string.h> < / span >
< a name = "l00046" > < / a > 00046
< a name = "l00047" > < / a > 00047 < span class = "keyword" > template< / span > < < span class = "keyword" > typename< / span > T>
< a name = "l00048" > < / a > < a class = "code" href = "class_vector3.html" > 00048< / a > < span class = "keyword" > class < / span > < a class = "code" href = "class_vector3.html" > Vector3< / a >
< a name = "l00049" > < / a > 00049 {
< a name = "l00050" > < / a > 00050 < span class = "keyword" > public< / span > :
< a name = "l00051" > < / a > < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > 00051< / a > T < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > , < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > , < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ;
< a name = "l00052" > < / a > 00052
< a name = "l00053" > < / a > 00053 < span class = "comment" > // trivial ctor< / span >
< a name = "l00054" > < / a > 00054 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > () {memset(< span class = "keyword" > this< / span > , 0, < span class = "keyword" > sizeof< / span > (*< span class = "keyword" > this< / span > ));}
< a name = "l00055" > < / a > 00055
< a name = "l00056" > < / a > 00056 < span class = "comment" > // setting ctor< / span >
< a name = "l00057" > < / a > 00057 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > (< span class = "keyword" > const< / span > T x0, < span class = "keyword" > const< / span > T y0, < span class = "keyword" > const< / span > T z0): < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > (x0), < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > (y0), < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > (z0) {}
< a name = "l00058" > < / a > 00058
< a name = "l00059" > < / a > 00059 < span class = "comment" > // function call operator< / span >
< a name = "l00060" > < / a > < a class = "code" href = "class_vector3.html#a593cdfdbdd00afcd740bc779cc6d9c73" > 00060< / a > < span class = "keywordtype" > void< / span > < a class = "code" href = "class_vector3.html#a593cdfdbdd00afcd740bc779cc6d9c73" > operator ()< / a > (< span class = "keyword" > const< / span > T x0, < span class = "keyword" > const< / span > T y0, < span class = "keyword" > const< / span > T z0)
< a name = "l00061" > < / a > 00061 { < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > = x0; < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > = y0; < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > = z0; }
< a name = "l00062" > < / a > 00062
< a name = "l00063" > < / a > 00063 < span class = "comment" > // test for equality< / span >
< a name = "l00064" > < / a > < a class = "code" href = "class_vector3.html#a306a028b0edcbbb511ff2a6ed0b58430" > 00064< / a > < span class = "keywordtype" > bool< / span > < a class = "code" href = "class_vector3.html#a306a028b0edcbbb511ff2a6ed0b58430" > operator==< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00065" > < / a > 00065 { < span class = "keywordflow" > return< / span > (< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > ==v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > & & < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > ==v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > & & < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ==v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ); }
< a name = "l00066" > < / a > 00066
< a name = "l00067" > < / a > 00067 < span class = "comment" > // test for inequality< / span >
< a name = "l00068" > < / a > < a class = "code" href = "class_vector3.html#a453097fe6164e4894fa419abc47dac8b" > 00068< / a > < span class = "keywordtype" > bool< / span > < a class = "code" href = "class_vector3.html#a453097fe6164e4894fa419abc47dac8b" > operator!=< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00069" > < / a > 00069 { < span class = "keywordflow" > return< / span > (< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > !=v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > || < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > !=v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > || < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > !=v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ); }
< a name = "l00070" > < / a > 00070
< a name = "l00071" > < / a > 00071 < span class = "comment" > // negation< / span >
< a name = "l00072" > < / a > < a class = "code" href = "class_vector3.html#a08b022c11e783bf75d32313b2dd39af7" > 00072< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a08b022c11e783bf75d32313b2dd39af7" > operator -< / a > (< span class = "keywordtype" > void< / span > )< span class = "keyword" > const< / span >
< a name = "l00073" > < / a > 00073 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > (-< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > ,-< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > ,-< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ); }
< a name = "l00074" > < / a > 00074
< a name = "l00075" > < / a > 00075 < span class = "comment" > // addition< / span >
< a name = "l00076" > < / a > < a class = "code" href = "class_vector3.html#a866eb5f699307c46abd919e9e28cf874" > 00076< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a866eb5f699307c46abd919e9e28cf874" > operator +< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)< span class = "keyword" > const< / span >
< a name = "l00077" > < / a > 00077 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > (< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > +v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > , < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > +v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > , < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > +v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ); }
< a name = "l00078" > < / a > 00078
< a name = "l00079" > < / a > 00079 < span class = "comment" > // subtraction< / span >
< a name = "l00080" > < / a > < a class = "code" href = "class_vector3.html#a628d97651648b0d46ebb0ecd60d357a1" > 00080< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a08b022c11e783bf75d32313b2dd39af7" > operator -< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)< span class = "keyword" > const< / span >
< a name = "l00081" > < / a > 00081 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > (< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > -v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > , < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > -v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > , < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > -v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ); }
< a name = "l00082" > < / a > 00082
< a name = "l00083" > < / a > 00083 < span class = "comment" > // uniform scaling< / span >
< a name = "l00084" > < / a > < a class = "code" href = "class_vector3.html#ab8eb35a54b6dc4a3180a8d44e8543826" > 00084< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#ab8eb35a54b6dc4a3180a8d44e8543826" > operator *< / a > (< span class = "keyword" > const< / span > T num)< span class = "keyword" > const< / span >
< a name = "l00085" > < / a > 00085 < span class = "keyword" > < / span > {
< a name = "l00086" > < / a > 00086 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > temp(*< span class = "keyword" > this< / span > );
< a name = "l00087" > < / a > 00087 < span class = "keywordflow" > return< / span > temp*=num;
< a name = "l00088" > < / a > 00088 }
< a name = "l00089" > < / a > 00089
< a name = "l00090" > < / a > 00090 < span class = "comment" > // uniform scaling< / span >
< a name = "l00091" > < / a > < a class = "code" href = "class_vector3.html#a15cf6a9c0d33483a58022a37372ad8e6" > 00091< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a15cf6a9c0d33483a58022a37372ad8e6" > operator /< / a > (< span class = "keyword" > const< / span > T num)< span class = "keyword" > const< / span >
< a name = "l00092" > < / a > 00092 < span class = "keyword" > < / span > {
< a name = "l00093" > < / a > 00093 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > temp(*< span class = "keyword" > this< / span > );
< a name = "l00094" > < / a > 00094 < span class = "keywordflow" > return< / span > temp/=num;
< a name = "l00095" > < / a > 00095 }
< a name = "l00096" > < / a > 00096
< a name = "l00097" > < / a > 00097 < span class = "comment" > // addition< / span >
< a name = "l00098" > < / a > < a class = "code" href = "class_vector3.html#a0bc5cd207aa5666973246dd002d856f0" > 00098< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & < a class = "code" href = "class_vector3.html#a0bc5cd207aa5666973246dd002d856f0" > operator +=< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00099" > < / a > 00099 {
< a name = "l00100" > < / a > 00100 < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > +=v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > ; < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > +=v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > ; < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > +=v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ;
< a name = "l00101" > < / a > 00101 < span class = "keywordflow" > return< / span > *< span class = "keyword" > this< / span > ;
< a name = "l00102" > < / a > 00102 }
< a name = "l00103" > < / a > 00103
< a name = "l00104" > < / a > 00104 < span class = "comment" > // subtraction< / span >
< a name = "l00105" > < / a > < a class = "code" href = "class_vector3.html#a5f8e3dfb7d3ecfc4e778c6028eccd174" > 00105< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & < a class = "code" href = "class_vector3.html#a5f8e3dfb7d3ecfc4e778c6028eccd174" > operator -=< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00106" > < / a > 00106 {
< a name = "l00107" > < / a > 00107 < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > -=v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > ; < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > -=v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > ; < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > -=v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ;
< a name = "l00108" > < / a > 00108 < span class = "keywordflow" > return< / span > *< span class = "keyword" > this< / span > ;
< a name = "l00109" > < / a > 00109 }
< a name = "l00110" > < / a > 00110
< a name = "l00111" > < / a > 00111 < span class = "comment" > // uniform scaling< / span >
< a name = "l00112" > < / a > < a class = "code" href = "class_vector3.html#aead20a9ece11ff71afeb9d0c4190192e" > 00112< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & < a class = "code" href = "class_vector3.html#aead20a9ece11ff71afeb9d0c4190192e" > operator *=< / a > (< span class = "keyword" > const< / span > T num)
< a name = "l00113" > < / a > 00113 {
< a name = "l00114" > < / a > 00114 < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > *=num; < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > *=num; < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > *=num;
< a name = "l00115" > < / a > 00115 < span class = "keywordflow" > return< / span > *< span class = "keyword" > this< / span > ;
< a name = "l00116" > < / a > 00116 }
< a name = "l00117" > < / a > 00117
< a name = "l00118" > < / a > 00118 < span class = "comment" > // uniform scaling< / span >
< a name = "l00119" > < / a > < a class = "code" href = "class_vector3.html#abdcdad88c66e4e056a0106627759b8cc" > 00119< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & < a class = "code" href = "class_vector3.html#abdcdad88c66e4e056a0106627759b8cc" > operator /=< / a > (< span class = "keyword" > const< / span > T num)
< a name = "l00120" > < / a > 00120 {
< a name = "l00121" > < / a > 00121 < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > /=num; < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > /=num; < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > /=num;
< a name = "l00122" > < / a > 00122 < span class = "keywordflow" > return< / span > *< span class = "keyword" > this< / span > ;
< a name = "l00123" > < / a > 00123 }
< a name = "l00124" > < / a > 00124
< a name = "l00125" > < / a > 00125 < span class = "comment" > // dot product< / span >
< a name = "l00126" > < / a > < a class = "code" href = "class_vector3.html#ac2a49fe3dff9cc7f16d6d1e76defdd47" > 00126< / a > T < a class = "code" href = "class_vector3.html#ab8eb35a54b6dc4a3180a8d44e8543826" > operator *< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)< span class = "keyword" > const< / span >
< a name = "l00127" > < / a > 00127 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > *v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > + < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > *v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > + < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > *v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > ; }
< a name = "l00128" > < / a > 00128
< a name = "l00129" > < / a > 00129 < span class = "comment" > // cross product< / span >
< a name = "l00130" > < / a > < a class = "code" href = "class_vector3.html#a58c19cb6972ba6efd05e05cde8af5b12" > 00130< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a58c19cb6972ba6efd05e05cde8af5b12" > operator %< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)< span class = "keyword" > const< / span >
< a name = "l00131" > < / a > 00131 < span class = "keyword" > < / span > {
< a name = "l00132" > < / a > 00132 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > temp(< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > *v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > - < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > *v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > , < a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > *v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > - < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > *v.< a class = "code" href = "class_vector3.html#ab3e7f5401dd6e951978bfa746809f74f" > z< / a > , < a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > *v.< a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > - < a class = "code" href = "class_vector3.html#a561df88b28e106e337a25bb86554a569" > y< / a > *v.< a class = "code" href = "class_vector3.html#a1a0f7e168c71ca798099f0ba8a444244" > x< / a > );
< a name = "l00133" > < / a > 00133 < span class = "keywordflow" > return< / span > temp;
< a name = "l00134" > < / a > 00134 }
< a name = "l00135" > < / a > 00135
< a name = "l00136" > < / a > 00136 < span class = "comment" > // gets the length of this vector squared< / span >
< a name = "l00137" > < / a > < a class = "code" href = "class_vector3.html#a2e22f60c089b1a0a554e697516e2c4dc" > 00137< / a > T < a class = "code" href = "class_vector3.html#a2e22f60c089b1a0a554e697516e2c4dc" > length_squared< / a > ()< span class = "keyword" > const< / span >
< a name = "l00138" > < / a > 00138 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > (T)(*< span class = "keyword" > this< / span > * *< span class = "keyword" > this< / span > ); }
< a name = "l00139" > < / a > 00139
< a name = "l00140" > < / a > 00140 < span class = "comment" > // gets the length of this vector< / span >
< a name = "l00141" > < / a > < a class = "code" href = "class_vector3.html#aeae8eae4d5a0a909aa0129c53c493038" > 00141< / a > < span class = "keywordtype" > float< / span > < a class = "code" href = "class_vector3.html#aeae8eae4d5a0a909aa0129c53c493038" > length< / a > ()< span class = "keyword" > const< / span >
< a name = "l00142" > < / a > 00142 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > (T)sqrt(*< span class = "keyword" > this< / span > * *< span class = "keyword" > this< / span > ); }
< a name = "l00143" > < / a > 00143
< a name = "l00144" > < / a > 00144 < span class = "comment" > // normalizes this vector< / span >
< a name = "l00145" > < / a > < a class = "code" href = "class_vector3.html#a9b147a862a1b86ed2e5b735d19da3da1" > 00145< / a > < span class = "keywordtype" > void< / span > < a class = "code" href = "class_vector3.html#a9b147a862a1b86ed2e5b735d19da3da1" > normalize< / a > ()
< a name = "l00146" > < / a > 00146 { *< span class = "keyword" > this< / span > /=< a class = "code" href = "class_vector3.html#aeae8eae4d5a0a909aa0129c53c493038" > length< / a > (); }
< a name = "l00147" > < / a > 00147
< a name = "l00148" > < / a > 00148 < span class = "comment" > // returns the normalized version of this vector< / span >
< a name = "l00149" > < / a > < a class = "code" href = "class_vector3.html#a4623c9d95850aec72ba56cb9ceea2cdf" > 00149< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a4623c9d95850aec72ba56cb9ceea2cdf" > normalized< / a > ()< span class = "keyword" > const< / span >
< a name = "l00150" > < / a > 00150 < span class = "keyword" > < / span > { < span class = "keywordflow" > return< / span > *< span class = "keyword" > this< / span > /< a class = "code" href = "class_vector3.html#aeae8eae4d5a0a909aa0129c53c493038" > length< / a > (); }
< a name = "l00151" > < / a > 00151
< a name = "l00152" > < / a > 00152 < span class = "comment" > // reflects this vector about n< / span >
< a name = "l00153" > < / a > < a class = "code" href = "class_vector3.html#a3a0d28e75255b664b54c82a7463eb698" > 00153< / a > < span class = "keywordtype" > void< / span > < a class = "code" href = "class_vector3.html#a3a0d28e75255b664b54c82a7463eb698" > reflect< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & n)
< a name = "l00154" > < / a > 00154 {
< a name = "l00155" > < / a > 00155 < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > orig(*< span class = "keyword" > this< / span > );
< a name = "l00156" > < / a > 00156 < a class = "code" href = "class_vector3.html#ae30e6927fbd51498d29413de4e175fcc" > project< / a > (n);
< a name = "l00157" > < / a > 00157 *< span class = "keyword" > this< / span > = *< span class = "keyword" > this< / span > *2 - orig;
< a name = "l00158" > < / a > 00158 }
< a name = "l00159" > < / a > 00159
< a name = "l00160" > < / a > 00160 < span class = "comment" > // projects this vector onto v< / span >
< a name = "l00161" > < / a > < a class = "code" href = "class_vector3.html#ae30e6927fbd51498d29413de4e175fcc" > 00161< / a > < span class = "keywordtype" > void< / span > < a class = "code" href = "class_vector3.html#ae30e6927fbd51498d29413de4e175fcc" > project< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00162" > < / a > 00162 { *< span class = "keyword" > this< / span > = v * (*< span class = "keyword" > this< / span > * v)/(v*v); }
< a name = "l00163" > < / a > 00163
< a name = "l00164" > < / a > 00164 < span class = "comment" > // returns this vector projected onto v< / span >
< a name = "l00165" > < / a > < a class = "code" href = "class_vector3.html#a314a68e23b8e72d1c86e8bc9736d6859" > 00165< / a > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > < a class = "code" href = "class_vector3.html#a314a68e23b8e72d1c86e8bc9736d6859" > projected< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v)
< a name = "l00166" > < / a > 00166 { < span class = "keywordflow" > return< / span > v * (*< span class = "keyword" > this< / span > * v)/(v*v); }
< a name = "l00167" > < / a > 00167
< a name = "l00168" > < / a > 00168 < span class = "comment" > // computes the angle between 2 arbitrary vectors< / span >
< a name = "l00169" > < / a > < a class = "code" href = "class_vector3.html#a2c465418f97886290fe0de26ce539601" > 00169< / a > T < a class = "code" href = "class_vector3.html#a2c465418f97886290fe0de26ce539601" > angle< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v1, < span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v2)
< a name = "l00170" > < / a > 00170 { < span class = "keywordflow" > return< / span > (T)acosf((v1*v2) / (v1.< a class = "code" href = "class_vector3.html#aeae8eae4d5a0a909aa0129c53c493038" > length< / a > ()*v2.length())); }
< a name = "l00171" > < / a > 00171
< a name = "l00172" > < / a > 00172 < span class = "comment" > // computes the angle between 2 arbitrary normalized vectors< / span >
< a name = "l00173" > < / a > < a class = "code" href = "class_vector3.html#aed71bc159e177cc91859c0d7da042279" > 00173< / a > T < a class = "code" href = "class_vector3.html#aed71bc159e177cc91859c0d7da042279" > angle_normalized< / a > (< span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v1, < span class = "keyword" > const< / span > < a class = "code" href = "class_vector3.html" > Vector3< T> < / a > & v2)
< a name = "l00174" > < / a > 00174 { < span class = "keywordflow" > return< / span > (T)acosf(v1*v2); }
< a name = "l00175" > < / a > 00175
< a name = "l00176" > < / a > 00176 };
< a name = "l00177" > < / a > 00177
< a name = "l00178" > < / a > < a class = "code" href = "vector3_8h.html#a6951accbbf6263a1ac8019bf718ae31c" > 00178< / a > < span class = "keyword" > typedef< / span > < a class = "code" href = "class_vector3.html" > Vector3< int> < / a > < a class = "code" href = "class_vector3.html" > Vector3i< / a > ;
< a name = "l00179" > < / a > < a class = "code" href = "vector3_8h.html#a6ec31b60b534f0303b042618762c2505" > 00179< / a > < span class = "keyword" > typedef< / span > < a class = "code" href = "class_vector3.html" > Vector3< unsigned int> < / a > < a class = "code" href = "class_vector3.html" > Vector3ui< / a > ;
< a name = "l00180" > < / a > < a class = "code" href = "vector3_8h.html#a1b41bd10c892aa9d109483fdd7fadc6e" > 00180< / a > < span class = "keyword" > typedef< / span > < a class = "code" href = "class_vector3.html" > Vector3< long> < / a > < a class = "code" href = "class_vector3.html" > Vector3l< / a > ;
< a name = "l00181" > < / a > < a class = "code" href = "vector3_8h.html#a6022fdc268104a3d8c7b92be8ddc6d89" > 00181< / a > < span class = "keyword" > typedef< / span > < a class = "code" href = "class_vector3.html" > Vector3< unsigned long> < / a > < a class = "code" href = "class_vector3.html" > Vector3ul< / a > ;
< a name = "l00182" > < / a > < a class = "code" href = "vector3_8h.html#af345ad77ba5e240c7ab72b4b2077e754" > 00182< / a > < span class = "keyword" > typedef< / span > < a class = "code" href = "class_vector3.html" > Vector3< float> < / a > < a class = "code" href = "class_vector3.html" > Vector3f< / a > ;
< a name = "l00183" > < / a > 00183
< a name = "l00184" > < / a > 00184 < span class = "preprocessor" > #endif // VECTOR3_H< / span >
< / pre > < / div > < / div >
< / div >
2010-12-26 23:23:35 -04:00
< hr class = "footer" / > < address class = "footer" > < small >
Generated for ArduPilot Libraries by < a href = "http://www.doxygen.org/index.html" > < img class = "footer" src = "doxygen.png" alt = "doxygen" / > < / a > < / small > < / address >
2010-12-26 20:59:17 -04:00
< / body >
< / html >