EMAN2
vec3.h
Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  *
00034  * */
00035 
00036 #ifndef eman__vec3_h__
00037 #define eman__vec3_h__ 1
00038 
00039 #include <vector>
00040 using std::vector;
00041 
00042 #include <cmath>
00043 
00044 #include <iostream>
00045 using std::cout;
00046 using std::endl;
00047 
00048 namespace EMAN
00049 {
00050 
00068         template<typename Type>
00069         class Vec4
00070         {
00071                 public:
00074                 typedef Type type;
00075                 
00076                 Vec4() 
00077                 {
00078                         vec[0] = static_cast<Type>(0);
00079                         vec[1] = static_cast<Type>(0);
00080                         vec[2] = static_cast<Type>(0);
00081                         vec[3] = static_cast<Type>(0);
00082                 }
00083                 
00084                 template<typename Type2, typename Type3, typename Type4, typename Type5>
00085                 Vec4(const Type2& a, const Type3& b, const Type4& c, const Type5& d)
00086                 {
00087                         vec[0] = static_cast<Type>(a);
00088                         vec[1] = static_cast<Type>(b);
00089                         vec[2] = static_cast<Type>(c);
00090                         vec[3] = static_cast<Type>(d);
00091                 }
00092                 
00097                 template<typename Type2>
00098                 Vec4(const vector < Type2 > &v)
00099                 {
00100                         vec[0] = static_cast<Type>(v[0]);
00101                         vec[1] = static_cast<Type>(v[1]);
00102                         vec[2] = static_cast<Type>(v[2]);
00103                         vec[3] = static_cast<Type>(v[3]);
00104                 }
00105 
00108                 template<typename Type2>
00109                 Vec4(const Vec4<Type2> &v)
00110                 {
00111                         vec[0] = v[0];
00112                         vec[1] = v[1];
00113                         vec[2] = v[2];
00114                         vec[2] = v[3];
00115                 }
00116                 
00119                 ~Vec4() {}
00120                 
00125                 float length() const
00126                 {
00127                         float t = (float)(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]);
00128                         return (float)sqrt(t);
00129                 }
00130                 
00135                 float normalize()
00136                 {
00137                         // Warning - float precision
00138                         float len = length();
00139                         if (len != 0) {
00140                                 vec[0] = static_cast<Type> (vec[0] / len);
00141                                 vec[1] = static_cast<Type> (vec[1] / len);
00142                                 vec[2] = static_cast<Type> (vec[2] / len);
00143                                 vec[3] = static_cast<Type> (vec[3] / len);
00144                         }
00145                         else {
00146                                 set_value(0, 0, 0, 0);  
00147                         }
00148                         return len;
00149                 }
00150                 
00155                 template<typename Type2>
00156                 void set_value(const vector < Type2 > &v)
00157                 {
00158                         vec[0] =  static_cast<Type>(v[0]);
00159                         vec[1] =  static_cast<Type>(v[1]);
00160                         vec[2] =  static_cast<Type>(v[2]);
00161                         vec[3] =  static_cast<Type>(v[3]);
00162                 }
00163 
00168                 template<typename Type2>
00169                 void set_value_at(int index, const Type2& value)
00170                 {
00171                         vec[index] = static_cast<Type>(value);
00172                 }
00173 
00179                 void set_value(const Type& a, const Type& b, const Type& c, const Type& d)
00180                 {
00181                         vec[0] =  a;
00182                         vec[1] =  b;
00183                         vec[2] =  c;
00184                         vec[3] =  d;
00185                 }
00186 
00194                 inline Type at(int i)
00195                 {
00196                         return vec[i];
00197                 }
00198                 
00203                 int number_of_element()
00204                 {
00205                         return 4;
00206                 }
00207 
00213                 Type * begin()
00214                 {
00215                         return &vec[0];
00216                 }
00217 
00223                 Type * end()
00224                 {
00225                         return &vec[4];
00226                 }
00227                 
00235                 inline Type operator[] (int i) const
00236                 {
00237                         return vec[i];
00238                 }
00239                 
00247                 inline Type& operator[] (int i)
00248                 {
00249                         return vec[i];
00250                 }
00251                 
00252                 private:
00253                         Type vec[4];
00254         };
00255         
00256         typedef Vec4<float> Vec4f;
00257         typedef Vec4<int> Vec4i;
00258         typedef Vec4<double> Vec4d;
00259         
00274         template<typename Type>
00275         class Vec3
00276         {
00277                 public:
00280                 typedef Type type;
00281 
00284                 Vec3() /*: vec[0](0),vec[1](0),vec[2](0)*/ {
00285 
00286                         vec[0] = static_cast<Type>(0);
00287                         vec[1] = static_cast<Type>(0);
00288                         vec[2] = static_cast<Type>(0);
00289                 }
00290 
00297                 template<typename Type2, typename Type3, typename Type4>
00298                 Vec3(const Type2& x, const Type3& y, const Type4& z = 0)
00299                 {
00300                         vec[0] = static_cast<Type>(x);
00301                         vec[1] = static_cast<Type>(y);
00302                         vec[2] = static_cast<Type>(z);
00303                 }
00304 
00309                 template<typename Type2>
00310                 Vec3(const vector < Type2 > &v)
00311                 {
00312                         vec[0] = static_cast<Type>(v[0]);
00313                         vec[1] = static_cast<Type>(v[1]);
00314                         vec[2] = static_cast<Type>(v[2]);
00315                 }
00316 
00319                 template<typename Type2>
00320                 Vec3(const Vec3<Type2> &v)
00321                 {
00322                         vec[0] = v[0];
00323                         vec[1] = v[1];
00324                         vec[2] = v[2];
00325                 }
00326 
00329                 ~Vec3() {}
00330 
00331 
00336                 float normalize()
00337                 {
00338                         // Warning - float precision
00339                         float len = length();
00340                         if (len != 0) {
00341                                 vec[0] = static_cast<Type> (vec[0] / len);
00342                                 vec[1] = static_cast<Type> (vec[1] / len);
00343                                 vec[2] = static_cast<Type> (vec[2] / len);
00344                         }
00345                         else {
00346                                 set_value(0, 0, 0);
00347                         }
00348                         return len;
00349                 }
00350 
00351 
00356                 float length() const
00357                 {
00358                         float t = (float)(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
00359                         return (float)sqrt(t);
00360                 }
00361 
00366                 Type squared_length() const
00367                 {
00368                         return  vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] ;
00369                 }
00370 
00376                 template<typename Type2>
00377                 Type dot(const Vec3<Type2> & v) const
00378                 {
00379                         return static_cast<Type>((vec[0] * v[0] + vec[1] * v[1] + vec[2] * v[2]));
00380                 }
00381 
00387                 template<typename Type2>
00388                 Vec3<Type> cross(const Vec3<Type2>  & v) const
00389                 {
00390                         return Vec3<Type>((vec[1] * v[2] - vec[2] * v[1]),
00391                                                   (vec[2] * v[0] - vec[0] * v[2]),
00392                                                    (vec[0] * v[1] - vec[1] * v[0]));
00393                 }
00394 
00398                 vector<Type> as_list() const
00399                 {
00400                         vector < Type > v(3);
00401                         v[0] = vec[0];
00402                         v[1] = vec[1];
00403                         v[2] = vec[2];
00404                         return v;
00405                 }
00406 
00411                 template<typename Type2>
00412                 void set_value(const vector < Type2 > &v)
00413                 {
00414                         vec[0] =  static_cast<Type>(v[0]);
00415                         vec[1] =  static_cast<Type>(v[1]);
00416                         vec[2] =  static_cast<Type>(v[2]);
00417                 }
00418 
00423                 template<typename Type2>
00424                 void set_value_at(int index, const Type2& value)
00425                 {
00426                         vec[index] = static_cast<Type>(value);
00427                 }
00428 
00434                 void set_value(const Type& x, const Type& y,  const Type& z)
00435                 {
00436                         vec[0] =  x;
00437                         vec[1] =  y;
00438                         vec[2] =  z;
00439                 }
00440 
00448                 inline Type operator[] (int i) const
00449                 {
00450                         return vec[i];
00451                 }
00452 
00460                 inline Type& operator[] (int i)
00461                 {
00462                         return vec[i];
00463                 }
00464 
00472                 inline Type at(int i)
00473                 {
00474                         return vec[i];
00475                 }
00476 
00481                 int number_of_element()
00482                 {
00483                         return 3;
00484                 }
00485 
00491                 Type * begin()
00492                 {
00493                         return &vec[0];
00494                 }
00495 
00501                 Type * end()
00502                 {
00503                         return &vec[3];
00504                 }
00505 
00510                 template<typename Type2>
00511                 Vec3<Type>& operator +=(const Vec3<Type2> &v) {
00512                         vec[0] = static_cast<Type>(vec[0]+v[0]);
00513                         vec[1] = static_cast<Type>(vec[1]+v[1]);
00514                         vec[2] = static_cast<Type>(vec[2]+v[2]);
00515                         return *this;
00516                 }
00517 
00522                 template<typename Type2>
00523                 Vec3<Type>  &operator +=(const Type2& d) {
00524                         vec[0] = static_cast<Type>(vec[0]+d);
00525                         vec[1] = static_cast<Type>(vec[1]+d);
00526                         vec[2] = static_cast<Type>(vec[2]+d);
00527                         return *this;
00528                 }
00529 
00534                 template<typename Type2>
00535                 Vec3<Type>  &operator -=(const Vec3<Type2> &v) {
00536                         vec[0] = static_cast<Type>(vec[0]-v[0]);
00537                         vec[1] = static_cast<Type>(vec[1]-v[1]);
00538                         vec[2] = static_cast<Type>(vec[2]-v[2]);
00539                         return *this;
00540                 }
00541 
00546                 template<typename Type2>
00547                 Vec3<Type>& operator -=(const Type2& d) {
00548                         vec[0] = static_cast<Type>(vec[0]-d);
00549                         vec[1] = static_cast<Type>(vec[1]-d);
00550                         vec[2] = static_cast<Type>(vec[2]-d);
00551                         return *this;
00552                 }
00553 
00558                 template<typename Type2>
00559                 Vec3<Type>  &operator *=(const Type2& d) {
00560                         vec[0] = static_cast<Type>(vec[0]*d);
00561                         vec[1] = static_cast<Type>(vec[1]*d);
00562                         vec[2] = static_cast<Type>(vec[2]*d);
00563                         return *this;
00564                 }
00565 
00570                 template<typename Type2>
00571                 Vec3<Type>  &operator /=(const Type2& d) {
00572                         vec[0] = static_cast<Type>(vec[0]/d);
00573                         vec[1] = static_cast<Type>(vec[1]/d);
00574                         vec[2] = static_cast<Type>(vec[2]/d);
00575                         return *this;
00576                 }
00577 
00578                 template<typename Type2>
00579                 operator vector<Type2>() const {
00580                         vector<Type2> v(vec,vec+3);
00581                         return v;
00582                 }
00583 
00584 
00585                 private:
00586                         Type vec[3];
00587         };
00588 
00589         template<typename Type,typename Type2>
00590         inline Vec3<Type> operator +(const Vec3<Type> &v1, const Vec3<Type2> &v2)
00591         {
00592 
00593                 return Vec3<Type>(static_cast<Type>(v1[0] + v2[0]), static_cast<Type>(v1[1] + v2[1]),static_cast<Type>(v1[2] + v2[2]));;
00594         }
00595 
00596         template<typename Type,typename Type2>
00597         inline Vec3<Type> operator +(const Vec3<Type> &v, const Type2& n)
00598         {
00599                 Vec3<Type> v1(v);
00600                 v1 += n;
00601                 return v1;
00602         }
00603 
00604 //      template<typename Type,typename Type2>
00605 //      inline Vec3<Type> operator +(const Type2& n, const Vec3<Type> &v)
00606 //      {
00607 //              Vec3<Type> v1(v);
00608 //              v1 += n;
00609 //              return v1;
00610 //      }
00611 
00612         template<typename Type,typename Type2>
00613         inline Vec3<Type> operator -(const Vec3<Type> &v1, const Vec3<Type2> &v2)
00614         {
00615                 return Vec3<Type>(static_cast<Type>(v1[0] - v2[0]),
00616                                                   static_cast<Type>(v1[1] - v2[1]),
00617                                                   static_cast<Type>(v1[2] - v2[2]));
00618         }
00619 
00620         template<typename Type,typename Type2>
00621         inline Vec3<Type> operator -(const Vec3<Type> &v, const Type2& n)
00622         {
00623                 Vec3<Type> v1(v);
00624                 v1 -= n;
00625                 return v1;
00626         }
00627         template<typename Type>
00628         inline Vec3<Type> operator -(const Vec3<Type> &v)
00629         {
00630                 return Vec3<Type>(-v[0],-v[1],-v[2]);
00631         }
00632 
00633 //      template<typename Type,typename Type2>
00634 //      inline Vec3<Type> operator -(const Type2& n, const Vec3<Type> &v)
00635 //      {
00636 //              Vec3<Type> v1(v);
00637 //              v1 -= n;
00638 //              return v1;
00639 //      }
00640 
00641         template<typename Type,typename Type2>
00642         inline Type operator *(const Vec3<Type> &v1, const Vec3<Type2> &v2)
00643         {
00644                 return v1.dot(v2);
00645         }
00646 
00647         template<typename Type,typename Type2>
00648         inline Vec3<Type2> operator *(const Type& d, const Vec3<Type2> & v)
00649         {
00650                 // Preserve the vector type
00651                 Vec3<Type2> v1(v);
00652                 v1 *= d;
00653                 return v1;
00654         }
00655 
00656         template<typename Type,typename Type2>
00657         inline Vec3<Type> operator *(const Vec3<Type> & v,const Type2& d) {
00658                 // Preserve the vector type
00659                 Vec3<Type> v1(v);
00660                 v1 *= d;
00661                 return v1;
00662         }
00663 
00664         template<typename Type,typename Type2>
00665         inline Vec3<Type2> operator /(const Type& d, const Vec3<Type2> & v)
00666         {
00667                 // Preserve the vector type
00668                 Vec3<Type2> v1(v);
00669                 v1 /= d;
00670                 return v1;
00671         }
00672 
00673         template<typename Type,typename Type2>
00674         inline Vec3<Type> operator /(const Vec3<Type> & v,const Type2& d) {
00675                 // Preserve the vector type
00676                 Vec3<Type> v1(v);
00677                 v1 /= d;
00678                 return v1;
00679         }
00680 
00681         template<typename Type,typename Type2>
00682         inline bool operator ==(const Vec3<Type> &v1, const Vec3<Type2> &v2) {
00683                 if (v1[0] == v2[0] && v1[1] == v2[1] && v1[2] == v2[2]) {
00684                         return true;
00685                 }
00686                 return false;
00687         }
00688 
00689         template<typename Type,typename Type2>
00690         inline bool operator !=(const Vec3<Type> &v1, const Vec3<Type2> &v2) {
00691                 if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
00692                         return true;
00693                 }
00694                 return false;
00695         }
00696 
00697         typedef Vec3<float> Vec3f;
00698         typedef Vec3<int> Vec3i;
00699         typedef Vec3<double> Vec3d;
00700 
00701 
00712         template<typename Type>
00713         class Vec2
00714         {
00715                 public:
00718                 typedef Type type;
00719 
00722                 Vec2() /*: vec[0](0),vec[1](0),vec[2](0)*/ {
00723                         vec[0] = static_cast<Type>(0);
00724                         vec[1] = static_cast<Type>(0);
00725                 }
00726 
00732                 template<typename Type2, typename Type3>
00733                 Vec2(const Type2& x, const Type3& y)
00734                 {
00735                         vec[0] = static_cast<Type>(x);
00736                         vec[1] = static_cast<Type>(y);
00737                 }
00738 
00743                 template<typename Type2>
00744                 Vec2(const vector < Type2 > &v)
00745                 {
00746                         vec[0] = static_cast<Type>(v[0]);
00747                         vec[1] = static_cast<Type>(v[1]);
00748                 }
00749 
00752                 template<typename Type2>
00753                 Vec2(const Vec2<Type2> &v)
00754                 {
00755                         vec[0] = static_cast<Type>(v[0]);
00756                         vec[1] = static_cast<Type>(v[1]);
00757                 }
00758 
00761                 ~Vec2() {}
00762 
00763 
00768                 float normalize()
00769                 {
00770                 // Warning - float precision
00771                         float len = length();
00772                         if (len != 0) {
00773                                 vec[0] = static_cast<Type> (vec[0] / len);
00774                                 vec[1] = static_cast<Type> (vec[1] / len);
00775                         }
00776                         else {
00777                                 set_value(0, 0);
00778                         }
00779                         return len;
00780                 }
00781 
00782 
00787                 float length() const
00788                 {
00789                         float t = (float)(vec[0] * vec[0] + vec[1] * vec[1]);
00790                         return (float)sqrt(t);
00791                 }
00792 
00797                 Type squared_length() const
00798                 {
00799                         return  vec[0] * vec[0] + vec[1] * vec[1] ;
00800                 }
00801 
00807                 template<typename Type2>
00808                 Type dot(const Vec2<Type2> & v) const
00809                 {
00810                         return static_cast<Type>((vec[0] * v[0] + vec[1] * v[1]));
00811                 }
00812 
00816                 vector<Type> as_list() const
00817                 {
00818                         vector < Type > v(2);
00819                         v[0] = vec[0];
00820                         v[1] = vec[1];
00821                         return v;
00822                 }
00823 
00828                 template<typename Type2>
00829                 void set_value(const vector < Type2 > &v)
00830                 {
00831                         vec[0] =  static_cast<Type>(v[0]);
00832                         vec[1] =  static_cast<Type>(v[1]);;
00833                 }
00834 
00839                 template<typename Type2>
00840                 void set_value_at(int index, const Type2& value)
00841                 {
00842                         vec[index] = static_cast<Type>(value);
00843                 }
00844 
00849                 void set_value(const Type& x, const Type& y)
00850                 {
00851                         vec[0] =  x;
00852                         vec[1] =  y;
00853                 }
00854 
00862                 inline Type operator[] (int i) const { return vec[i]; }
00863 
00871                 inline Type& operator[] (int i) { return vec[i]; }
00872 
00880                 inline Type at(int i) { return vec[i]; }
00881 
00882 
00887                 int number_of_element()
00888                 {
00889                         return 2;
00890                 }
00891 
00897                 Type * begin()
00898                 {
00899                         return &vec[0];
00900                 }
00901 
00907                 Type * end()
00908                 {
00909                         return &vec[2];
00910                 }
00911 
00912 
00917                 template<typename Type2>
00918                 Vec2<Type>& operator +=(const Vec2<Type2> &v) {
00919                         vec[0] = static_cast<Type>(vec[0]+v[0]);
00920                         vec[1] = static_cast<Type>(vec[1]+v[1]);
00921                         return *this;
00922                 }
00923 
00928                 template<typename Type2>
00929                 Vec2<Type>& operator +=(const Type2& d) {
00930                         vec[0] = static_cast<Type>(vec[0]+d);
00931                         vec[1] = static_cast<Type>(vec[1]+d);
00932                         return *this;
00933                 }
00934 
00939                 template<typename Type2>
00940                 Vec2<Type>& operator -=(const Vec2<Type2> &v) {
00941                         vec[0] = static_cast<Type>(vec[0]-v[0]);
00942                         vec[1] = static_cast<Type>(vec[1]-v[1]);
00943                         return *this;
00944                 }
00945 
00950                 template<typename Type2>
00951                 Vec2<Type>& operator -=(const Type2& d) {
00952                         vec[0] = static_cast<Type>(vec[0]-d);
00953                         vec[1] = static_cast<Type>(vec[1]-d);
00954                         return *this;
00955                 }
00956 
00961                 template<typename Type2>
00962                 Vec2<Type>& operator *=(const Type2& d) {
00963                         vec[0] = static_cast<Type>(vec[0]*d);
00964                         vec[1] = static_cast<Type>(vec[1]*d);
00965                         return *this;
00966                 }
00967 
00972                 template<typename Type2>
00973                 Vec2<Type>& operator /=(const Type2& d) {
00974                         vec[0] = static_cast<Type>(vec[0]/d);
00975                         vec[1] = static_cast<Type>(vec[1]/d);
00976                         return *this;
00977                 }
00978 
00979 
00980                 private:
00981                         Type vec[2];
00982         };
00983 
00984         template<typename Type,typename Type2>
00985         inline Vec2<Type> operator +(const Vec2<Type> &v1, const Vec2<Type2> &v2)
00986         {
00987                 return Vec2<Type>(static_cast<Type>(v1[0] + v2[0]), static_cast<Type>(v1[1] + v2[1]));;
00988         }
00989 
00990         template<typename Type,typename Type2>
00991         inline Vec2<Type> operator +(const Vec2<Type> &v, const Type2& n)
00992         {
00993                 Vec2<Type> v1(v);
00994                 v1 += n;
00995                 return v1;
00996         }
00997 
00998         template<typename Type,typename Type2>
00999         inline Vec2<Type> operator -(const Vec2<Type> &v1, const Vec2<Type2> &v2)
01000         {
01001                 return Vec2<Type>(static_cast<Type>(v1[0] - v2[0]),     static_cast<Type>(v1[1] - v2[1]));
01002         }
01003 
01004         template<typename Type,typename Type2>
01005         inline Vec2<Type> operator -(const Vec2<Type> &v, const Type2& n)
01006         {
01007                 Vec2<Type> v1(v);
01008                 v1 -= n;
01009                 return v1;
01010         }
01011 
01012         template<typename Type>
01013         inline Vec2<Type> operator -(const Vec2<Type> &v)
01014         {
01015                 return Vec2<Type>(-v[0],-v[1]);
01016         }
01017 
01018 
01019         template<typename Type,typename Type2>
01020         inline Type operator *(const Vec2<Type> &v1, const Vec2<Type2> &v2)
01021         {
01022                 return v1.dot(v2);
01023         }
01024 
01025         template<typename Type,typename Type2>
01026         inline Vec2<Type2> operator *(const Type& d, const Vec2<Type2> & v)
01027         {
01028                 // Preserve the vector type
01029                 Vec2<Type2> v1(v);
01030                 v1 *= d;
01031                 return v1;
01032         }
01033 
01034         template<typename Type,typename Type2>
01035         inline Vec2<Type> operator *(const Vec2<Type> & v,const Type2& d) {
01036         // Preserve the vector type
01037                 Vec2<Type> v1(v);
01038                 v1 *= d;
01039                 return v1;
01040         }
01041 
01042         template<typename Type,typename Type2>
01043         inline Vec2<Type2> operator /(const Type& d, const Vec2<Type2> & v)
01044         {
01045         // Preserve the vector type
01046                 Vec2<Type2> v1(v);
01047                 v1 /= d;
01048                 return v1;
01049         }
01050 
01051         template<typename Type,typename Type2>
01052         inline Vec2<Type> operator /(const Vec2<Type> & v,const Type2& d) {
01053                 // Preserve the vector type
01054                 Vec2<Type> v1(v);
01055                 v1 /= d;
01056                 return v1;
01057         }
01058 
01059         template<typename Type,typename Type2>
01060         inline bool operator ==(const Vec2<Type> &v1, const Vec2<Type2> &v2) {
01061                 if (v1[0] == v2[0] && v1[1] == v2[1] ) {
01062                         return true;
01063                 }
01064                 return false;
01065         }
01066 
01067         template<typename Type,typename Type2>
01068         inline bool operator !=(const Vec2<Type> &v1, const Vec2<Type2> &v2) {
01069                 if (v1[0] != v2[0] || v1[1] != v2[1] ) {
01070                         return true;
01071                 }
01072                 return false;
01073         }
01074 
01075         typedef Vec2<float> Vec2f;
01076         typedef Vec2<int> Vec2i;
01077         typedef Vec2<double> Vec2d;
01078 }
01079 #endif