From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/vectord__inline_8h-source.html | 262 ++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 docs/doxygen/nel/vectord__inline_8h-source.html (limited to 'docs/doxygen/nel/vectord__inline_8h-source.html') diff --git a/docs/doxygen/nel/vectord__inline_8h-source.html b/docs/doxygen/nel/vectord__inline_8h-source.html new file mode 100644 index 00000000..8a18b335 --- /dev/null +++ b/docs/doxygen/nel/vectord__inline_8h-source.html @@ -0,0 +1,262 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

vectord_inline.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 
+00027 #ifndef NL_VECTORD_INLINE_H
+00028 #define NL_VECTORD_INLINE_H
+00029 
+00030 
+00031 #include "nel/misc/common.h"
+00032 
+00033 
+00034 namespace       NLMISC
+00035 {
+00036 
+00037 
+00038 // ============================================================================================
+00039 // Base Maths.
+00040 inline  CVectorD        &CVectorD::operator+=(const CVectorD &v)
+00041 {
+00042         x+=v.x;
+00043         y+=v.y;
+00044         z+=v.z;
+00045         return *this;
+00046 }
+00047 inline  CVectorD        &CVectorD::operator-=(const CVectorD &v)
+00048 {
+00049         x-=v.x;
+00050         y-=v.y;
+00051         z-=v.z;
+00052         return *this;
+00053 }
+00054 inline  CVectorD        &CVectorD::operator*=(double f)
+00055 {
+00056         x*=f;
+00057         y*=f;
+00058         z*=f;
+00059         return *this;
+00060 }
+00061 inline  CVectorD        &CVectorD::operator/=(double f)
+00062 {
+00063         return *this*= (1.0f/f);
+00064 }
+00065 inline  CVectorD        CVectorD::operator+(const CVectorD &v) const
+00066 {
+00067         CVectorD        ret(x+v.x, y+v.y, z+v.z);
+00068         return ret;
+00069 }
+00070 inline  CVectorD        CVectorD::operator-(const CVectorD &v) const
+00071 {
+00072         CVectorD        ret(x-v.x, y-v.y, z-v.z);
+00073         return ret;
+00074 }
+00075 inline  CVectorD        CVectorD::operator*(double f) const
+00076 {
+00077         CVectorD        ret(x*f, y*f, z*f);
+00078         return ret;
+00079 }
+00080 inline  CVectorD        CVectorD::operator/(double f) const
+00081 {
+00082         return *this*(1.0f/f);
+00083 }
+00084 inline  CVectorD        CVectorD::operator-() const
+00085 {
+00086         return CVectorD(-x,-y,-z);
+00087 }
+00088 inline CVectorD operator*(double f, const CVectorD &v)
+00089 {
+00090         CVectorD        ret(v.x*f, v.y*f, v.z*f);
+00091         return ret;
+00092 }
+00093 
+00094 
+00095 // ============================================================================================
+00096 // Advanced Maths.
+00097 inline  double  CVectorD::operator*(const CVectorD &v) const
+00098 {
+00099         return x*v.x + y*v.y + z*v.z;
+00100 }
+00101 inline  CVectorD        CVectorD::operator^(const CVectorD &v) const
+00102 {
+00103         CVectorD        ret;
+00104 
+00105         ret.x= y*v.z - z*v.y;
+00106         ret.y= z*v.x - x*v.z;
+00107         ret.z= x*v.y - y*v.x;
+00108 
+00109         return ret;
+00110 }
+00111 inline  double  CVectorD::sqrnorm() const
+00112 {
+00113         return (double)(x*x + y*y + z*z);
+00114 }
+00115 inline  double  CVectorD::norm() const
+00116 {
+00117         return (double)sqrt(x*x + y*y + z*z);
+00118 }
+00119 inline  void    CVectorD::normalize()
+00120 {
+00121         double  n=norm();
+00122         if(n)
+00123                 *this/=n;
+00124 }
+00125 inline  CVectorD        CVectorD::normed() const
+00126 {
+00127         CVectorD        ret;
+00128         ret= *this;
+00129         ret.normalize();
+00130         return ret;
+00131 }
+00132 
+00133 
+00134 // ============================================================================================
+00135 // Misc.
+00136 inline  void    CVectorD::set(double _x, double _y, double _z)
+00137 {
+00138         x=_x; y=_y; z=_z;
+00139 }
+00140 inline  bool    CVectorD::operator==(const CVectorD &v) const 
+00141 {
+00142         return x==v.x && y==v.y && z==v.z;
+00143 }
+00144 inline  bool    CVectorD::operator!=(const CVectorD &v) const 
+00145 {
+00146         return !(*this==v);
+00147 }
+00148 inline  bool    CVectorD::isNull() const
+00149 {
+00150         return *this==CVectorD::Null;
+00151 }
+00152 inline  void    CVectorD::cartesianToSpheric(double &r, double &theta,double &phi) const
+00153 {
+00154         CVectorD v;
+00155 
+00156         r= norm();
+00157         v= normed();
+00158 
+00159         // phi E [-PI/2 et PI/2]
+00160         clamp(v.z, -1.0, 1.0);
+00161         phi=asin(v.z);
+00162 
+00163         // theta [-PI,PI]
+00164         theta=atan2(v.y,v.x);
+00165 }
+00166 inline  void    CVectorD::sphericToCartesian(double r, double theta,double phi)
+00167 {
+00168         x= r*cos(theta)*cos(phi);
+00169         y= r*sin(theta)*cos(phi);
+00170         z= r*sin(phi);
+00171 }
+00172 inline CVectorD &CVectorD::operator=(const CVector &v)
+00173 {
+00174         x=v.x;
+00175         y=v.y;
+00176         z=v.z;
+00177         return *this;
+00178 }
+00179 inline CVectorD::operator CVector() const
+00180 {
+00181         return CVector((float)x, (float)y, (float)z);
+00182 }
+00183 inline  void    CVectorD::serial(IStream &f)
+00184 {
+00185         f.serial(x,y,z);
+00186 }
+00187 
+00188 
+00189 }
+00190 
+00191 
+00192 #endif
+00193 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1