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__2f_8h-source.html | 199 +++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 docs/doxygen/nel/vector__2f_8h-source.html (limited to 'docs/doxygen/nel/vector__2f_8h-source.html') diff --git a/docs/doxygen/nel/vector__2f_8h-source.html b/docs/doxygen/nel/vector__2f_8h-source.html new file mode 100644 index 00000000..0a919ee5 --- /dev/null +++ b/docs/doxygen/nel/vector__2f_8h-source.html @@ -0,0 +1,199 @@ + + + + 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_2f.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_2F_H
+00027 #define NL_VECTOR_2F_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/vector.h"
+00031 #include <math.h>
+00032 #include "nel/misc/stream.h"
+00033 #include <string>
+00034 
+00035 
+00036 namespace NLMISC
+00037 {
+00038 
+00039 
+00040 // ***************************************************************************
+00047 class CVector2f
+00048 {
+00049 public:
+00050 
+00051 public:         // Attributes.
+00052         float   x,y;
+00053 
+00054 public:         // Methods.
+00056 
+00057 
+00058         CVector2f() {}
+00060         CVector2f(float _x, float _y) : x(_x), y(_y) {}
+00062         CVector2f(const CVector2f &v) : x(v.x), y(v.y) {}
+00064         CVector2f(const CVector &v) : x(v.x), y(v.y) {}
+00065         // conversion operator
+00066         operator CVector() const { return this->asVector(); }
+00067         // convert to a CVector by setting z to 0
+00068         CVector  asVector() const { return CVector(x, y, 0); }
+00070 
+00072 
+00073         CVector2f       &operator+=(const CVector2f &v)         {x+=v.x; y+=v.y; return *this;}
+00074         CVector2f       &operator-=(const CVector2f &v)         {x-=v.x; y-=v.y; return *this;}
+00075         CVector2f       &operator*=(float f)                            {x*=f; y*=f; return *this;}
+00076         CVector2f       &operator/=(float f)                            {x/=f; y/=f; return *this;}
+00077         CVector2f       operator+(const CVector2f &v) const     {return CVector2f(x+v.x, y+v.y);}
+00078         CVector2f       operator-(const CVector2f &v) const     {return CVector2f(x-v.x, y-v.y);}
+00079         CVector2f       operator*(float f) const                        {return CVector2f(x*f, y*f);}
+00080         CVector2f       operator/(float f) const                        {return CVector2f(x/f, y/f);}
+00081         CVector2f       operator-() const                                       {return CVector2f(-x, -y);}
+00083 
+00085 
+00086 
+00087         float   operator*(const CVector2f &v) const             {return x*v.x + y*v.y;}
+00089         float   norm() const                                                    {return (float)sqrt(sqrnorm());}
+00091         float   sqrnorm() const                                                 {return x*x + y*y;}
+00093         void    normalize()
+00094         {
+00095                 float   f= norm();
+00096                 if(f>0)
+00097                         *this/=f;
+00098         }
+00100         CVector2f       normed() const
+00101         {
+00102                 CVector2f       v= *this;
+00103                 v.normalize();
+00104                 return v;
+00105         }
+00107 
+00109 
+00110         void    set(float _x, float _y)                                 {x= _x; y=_y;}
+00111         bool    operator==(const CVector2f &v) const    {return x==v.x && y==v.y;}
+00112         bool    operator!=(const CVector2f &v) const    {return !(*this==v);}
+00113         bool    isNull() const                                                  {return x==0.0f && y==0.0f;}
+00115         void    minof(const CVector2f &a, const CVector2f &b)
+00116         {
+00117                 x= std::min(a.x, b.x);
+00118                 y= std::min(a.y, b.y);
+00119         }
+00121         void    maxof(const CVector2f &a, const CVector2f &b)
+00122         {
+00123                 x= std::max(a.x, b.x);
+00124                 y= std::max(a.y, b.y);
+00125         }
+00127         void    serial(NLMISC::IStream &f)                              {f.serial(x,y);}
+00129 
+00130         // friends.
+00131         friend  CVector2f       operator*(float f, const CVector2f &v0);
+00132 
+00134 
+00135         static const CVector2f Null;
+00137 };
+00138 
+00139 
+00140 inline  CVector2f       operator*(float f, const CVector2f &v)
+00141 {
+00142         return v*f;
+00143 }
+00144 
+00145 // for map/set insertion
+00146 inline bool operator < (const CVector2f &lhs, const CVector2f &rhs)
+00147 {
+00148         return (lhs.x != rhs.x) ? lhs.x < rhs.x : lhs.y < rhs.y;        
+00149 }
+00150 
+00151 } // NLMISC
+00152 
+00153 
+00154 #endif // NL_VECTOR_2F_H
+00155 
+00156 /* End of vector_2f.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1