Home | nevrax.com |
|
vectord.hGo 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 #ifndef NL_VECTORD_H 00027 #define NL_VECTORD_H 00028 00029 #include <math.h> 00030 #include "nel/misc/vector.h" 00031 00032 00033 namespace NLMISC 00034 { 00035 00036 00037 // ====================================================================================================== 00044 class CVectorD 00045 { 00046 public: // Attributes. 00047 double x,y,z; 00048 00049 public: // const. 00051 static const CVectorD Null; 00053 static const CVectorD I; 00055 static const CVectorD J; 00057 static const CVectorD K; 00058 00059 public: // Methods. 00061 00062 00063 CVectorD() {} 00065 CVectorD(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {} 00067 CVectorD(const CVector &v) : x(v.x), y(v.y), z(v.z) {} 00069 CVectorD(const CVectorD &v) : x(v.x), y(v.y), z(v.z) {} 00071 00073 00074 CVectorD &operator+=(const CVectorD &v); 00075 CVectorD &operator-=(const CVectorD &v); 00076 CVectorD &operator*=(double f); 00077 CVectorD &operator/=(double f); 00078 CVectorD operator+(const CVectorD &v) const; 00079 CVectorD operator-(const CVectorD &v) const; 00080 CVectorD operator*(double f) const; 00081 CVectorD operator/(double f) const; 00082 CVectorD operator-() const; 00084 00086 00087 00088 double operator*(const CVectorD &v) const; 00092 CVectorD operator^(const CVectorD &v) const; 00094 double norm() const; 00096 double sqrnorm() const; 00098 void normalize(); 00100 CVectorD normed() const; 00102 00104 00105 void set(double _x, double _y, double _z); 00106 bool operator==(const CVectorD &v) const; 00107 bool operator!=(const CVectorD &v) const; 00108 bool isNull() const; 00118 void sphericToCartesian(double r, double theta,double phi); 00124 void cartesianToSpheric(double &r, double &theta,double &phi) const; 00125 void serial(IStream &f); 00126 CVectorD &operator=(const CVector &v); 00127 operator CVector() const; 00129 00130 // friends. 00131 friend CVectorD operator*(double f, const CVectorD &v0); 00132 }; 00133 00134 00135 } 00136 00137 00138 #include "nel/misc/vectord_inline.h" 00139 00140 00141 #endif // NL_VECTOR_H 00142 00143 /* End of vector.h */ |