00001 #ifndef _MYVECTOR_H_ 00002 #define _MYVECTOR_H_ 00003 00004 #include <cmath> 00005 #include <iostream> 00006 #include <string> 00007 00008 00010 00013 namespace MyMath 00014 { 00016 00020 class MyMathException 00021 { 00022 private: 00024 00028 std::string mesg; 00029 public: 00031 00037 MyMathException(std::string _mesg); 00039 00042 std::string giveMessage(); 00044 void printMessage(); 00045 }; 00046 00047 00049 00053 class Vector 00054 { 00055 private: 00057 double x; 00059 double y; 00061 double z; 00062 public: 00064 00068 Vector(); 00070 00077 Vector(double _x,double _y,double _z); 00078 00080 00084 void operator=(Vector const &otherVec); 00085 00087 00092 double operator[](unsigned int index); 00093 00095 00098 Vector& operator+(Vector const &otherVec); 00099 00101 00104 Vector& operator-(Vector const &otherVec); 00105 00107 00110 Vector& operator*(double scalar); 00111 00113 00117 double operator*(Vector const &otherVec); 00118 00120 double norm(); 00121 00123 void print(); 00124 }; 00125 Vector cross_product(Vector v1,Vector v2); 00126 }; 00127 #endif