00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ExCVec3D.h"
00025
00026
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
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
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
00141
00142
00143
00144
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 }