Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExCVec3D.cpp

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExCVec3D.cpp,v 1.8 2002/11/09 16:09:42 data Exp $
00021  *
00022  */
00023 
00024 #include "ExCVec3D.h"
00025 
00026 // Construction/Destruction
00027 
00028 ExCVec3D::ExCVec3D()
00029 {
00030         SetValue(0,0,0);
00031 }
00032 
00033 ExCVec3D::ExCVec3D(float x,float y,float z)
00034 {
00035         SetValue(x,y,z);
00036 }
00037 
00038 ExCVec3D::ExCVec3D(float x,float y)
00039 {
00040         SetValue(x,y,0);
00041 }
00042 
00043 ExCVec3D::ExCVec3D(float x)
00044 {
00045         SetValue(x,0,0);
00046 }
00047 
00048 ExCVec3D::ExCVec3D(const ExCVec3D &vec)
00049 {
00050         SetValue(vec.m_Vector[0],vec.m_Vector[1],vec.m_Vector[2]);
00051 }
00052 
00053 ExCVec3D::~ExCVec3D()
00054 {
00055 
00056 }
00057 
00058 // Methode
00059 
00060 float ExCVec3D::GetVectorLenght(void)
00061 {
00062         return sqrt((m_Vector[0]*m_Vector[0])+(m_Vector[1]*m_Vector[1])+(m_Vector[2]*m_Vector[2]));
00063 }
00064 ExCVec3D ExCVec3D::GetVecNormale(void)
00065 {
00066         ExCVec3D VecNorm;
00067         VecNorm=*this;
00068         VecNorm=*this/this->GetVectorLenght();
00069         return VecNorm;
00070 }
00071 void ExCVec3D::SetValue(float x,float y,float z)
00072 {
00073         m_Vector[0]=x;
00074         m_Vector[1]=y;
00075         m_Vector[2]=z;
00076 }
00077 
00078 // Operator surcharge
00079 ExCVec3D& ExCVec3D::operator =(const ExCVec3D& Vec)
00080 {
00081         SetValue(Vec.m_Vector[0],Vec.m_Vector[1],Vec.m_Vector[2]);
00082         return *this;
00083 }
00084 bool  ExCVec3D::operator==(const ExCVec3D& Vec)
00085 {
00086         if(m_Vector[0]==Vec.m_Vector[0]||m_Vector[1]==Vec.m_Vector[1]||m_Vector[2]==Vec.m_Vector[2]) return true;
00087         else return false;
00088 }
00089 
00090 ExCVec3D  ExCVec3D::operator+(const ExCVec3D& Vec)
00091 {
00092         return ExCVec3D(m_Vector[0]+Vec.m_Vector[0],m_Vector[1]+Vec.m_Vector[1],m_Vector[2]+Vec.m_Vector[2]);
00093 }
00094 
00095 ExCVec3D  ExCVec3D::operator-(const ExCVec3D& Vec)
00096 {
00097         return ExCVec3D(m_Vector[0]-Vec.m_Vector[0],m_Vector[1]-Vec.m_Vector[1],m_Vector[2]-Vec.m_Vector[2]);
00098 }
00099 
00100 ExCVec3D  ExCVec3D::operator*(const ExCVec3D& Vec)
00101 {
00102         return ExCVec3D(m_Vector[0]*Vec.m_Vector[0],m_Vector[1]*Vec.m_Vector[1],m_Vector[2]*Vec.m_Vector[2]);
00103 }
00104 
00105 ExCVec3D  ExCVec3D::operator*(float scalar)
00106 {
00107         return ExCVec3D(m_Vector[0]*scalar,m_Vector[1]*scalar,m_Vector[2]*scalar);
00108 }
00109 
00110 ExCVec3D  ExCVec3D::operator/(const ExCVec3D& Vec)
00111 {
00112         return ExCVec3D(m_Vector[0]/Vec.m_Vector[0],m_Vector[1]/Vec.m_Vector[1],m_Vector[2]/Vec.m_Vector[2]);
00113 }
00114 
00115 ExCVec3D  ExCVec3D::operator/(float scalar)
00116 {
00117         return ExCVec3D(m_Vector[0]/scalar,m_Vector[1]/scalar,m_Vector[2]/scalar);
00118 }
00119 
00120 ExCVec3D  ExCVec3D::operator++()
00121 {
00122         m_Vector[0]++;m_Vector[1]++;m_Vector[2]++;
00123         return *this;
00124 }
00125 ExCVec3D  ExCVec3D::operator++(int)
00126 {
00127         m_Vector[0]++;m_Vector[1]++;m_Vector[2]++;
00128         return *this;
00129 }
00130 ExCVec3D  ExCVec3D::operator--()
00131 {
00132         m_Vector[0]--;m_Vector[1]--;m_Vector[2]--;
00133         return *this;
00134 }
00135 ExCVec3D  ExCVec3D::operator--(int)
00136 {
00137         m_Vector[0]--;m_Vector[1]--;m_Vector[2]--;
00138         return *this;
00139 }
00140 /*ExCVec3D  ExCVec3D::operator+=(const ExCVec3D& Vec)
00141 {
00142         
00143 }*/
00144 // Friends
00145 std::ostream& operator<<(std::ostream& s,const ExCVec3D &vec)
00146 {
00147         s<<"X:"<<(float)vec.m_Vector[0]<<" Y:"<<(float)vec.m_Vector[1]<<" Z:"<<(float)vec.m_Vector[2];
00148         return s;
00149 }
00150 std::ostrstream& operator<<(std::ostrstream& s,const ExCVec3D &vec)
00151 {
00152         s<<"X:"<<(float)vec.m_Vector[0]<<" Y:"<<(float)vec.m_Vector[1]<<" Z:"<<(float)vec.m_Vector[2];
00153         return s;
00154 }

Generated on Tue Dec 10 18:20:05 2002 for ExNihilo by doxygen1.3-rc1