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/vector__2d_8h-source.html | 190 +++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 docs/doxygen/nel/vector__2d_8h-source.html (limited to 'docs/doxygen/nel/vector__2d_8h-source.html') diff --git a/docs/doxygen/nel/vector__2d_8h-source.html b/docs/doxygen/nel/vector__2d_8h-source.html new file mode 100644 index 00000000..5abfc6f1 --- /dev/null +++ b/docs/doxygen/nel/vector__2d_8h-source.html @@ -0,0 +1,190 @@ + + + + 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  
+

vector_2d.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 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 #ifndef NL_VECTOR_2D_H
+00027 #define NL_VECTOR_2D_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 
+00031 #include <math.h>
+00032 #include <string>
+00033 
+00034 #include "nel/misc/stream.h"
+00035 #include "nel/misc/vector_2f.h"
+00036 
+00037 namespace NLMISC
+00038 {
+00039 
+00040 
+00041 // ***************************************************************************
+00048 class CVector2d
+00049 {
+00050 public:
+00051 
+00052 public:         // Attributes.
+00053         double  x,y;
+00054 
+00055 public:         // Methods.
+00057 
+00058 
+00059         CVector2d() {}
+00061         CVector2d(double        _x, double _y) : x(_x), y(_y) {}
+00063         CVector2d(const CVector2d &v) : x(v.x), y(v.y) {}
+00065         CVector2d(const CVector2f &v) : x(v.x), y(v.y) {}
+00066 
+00068 
+00070 
+00071         CVector2d       &operator+=(const CVector2d &v)         {x+=v.x; y+=v.y; return *this;}
+00072         CVector2d       &operator-=(const CVector2d &v)         {x-=v.x; y-=v.y; return *this;}
+00073         CVector2d       &operator*=(double f)                           {x*=f; y*=f; return *this;}
+00074         CVector2d       &operator/=(double f)                           {x/=f; y/=f; return *this;}
+00075         CVector2d       operator+(const CVector2d &v) const     {return CVector2d(x+v.x, y+v.y);}
+00076         CVector2d       operator-(const CVector2d &v) const     {return CVector2d(x-v.x, y-v.y);}
+00077         CVector2d       operator*(double f) const                       {return CVector2d(x*f, y*f);}
+00078         CVector2d       operator/(double f) const                       {return CVector2d(x/f, y/f);}
+00079         CVector2d       operator-() const                                       {return CVector2d(-x, -y);}
+00081 
+00083 
+00084 
+00085         double  operator*(const CVector2d &v) const             {return x*v.x + y*v.y;}
+00087         double  norm() const                                                    {return (double)sqrt(sqrnorm());}
+00089         double  sqrnorm() const                                                 {return x*x + y*y;}
+00091         void    normalize()
+00092         {
+00093                 double  f= norm();
+00094                 if(f>0)
+00095                         *this/=f;
+00096         }
+00098         CVector2d       normed() const
+00099         {
+00100                 CVector2d       v= *this;
+00101                 v.normalize();
+00102                 return v;
+00103         }
+00105 
+00107 
+00108         void    set(double _x, double _y)                                       {x= _x; y=_y;}
+00109         bool    operator==(const CVector2d &v) const    {return x==v.x && y==v.y;}
+00110         bool    operator!=(const CVector2d &v) const    {return !(*this==v);}
+00111         bool    isNull() const                                                  {return x==0.0f && y==0.0f;}
+00113         void    minof(const CVector2d &a, const CVector2d &b)
+00114         {
+00115                 x= std::min(a.x, b.x);
+00116                 y= std::min(a.y, b.y);
+00117         }
+00119         void    maxof(const CVector2d &a, const CVector2d &b)
+00120         {
+00121                 x= std::max(a.x, b.x);
+00122                 y= std::max(a.y, b.y);
+00123         }
+00125         void    serial(NLMISC::IStream &f)                              {f.serial(x,y);}
+00127 
+00128         // friends.
+00129         friend  CVector2d       operator*(double f, const CVector2d &v0);
+00130 
+00131 };
+00132 
+00133 
+00134 inline  CVector2d       operator*(double f, const CVector2d &v)
+00135 {
+00136         return v*f;
+00137 }
+00138 
+00139 
+00140 } // NLMISC
+00141 
+00142 
+00143 #endif // NL_VECTOR_2D_H
+00144 
+00145 /* End of vector_2d.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1