00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VECTOR3D__
00024 #define __VECTOR3D__
00025
00026 #include <math.h>
00027 #include <string>
00028
00029 #define Point3d Vector3d
00030
00031 class BoundingBox;
00032 class Matrix3x3;
00033 class Quaternion;
00034
00035
00036
00037
00038
00039
00040
00041
00042 class Vector3d{
00043 protected:
00044
00045 double x,y,z;
00046 public:
00047 Vector3d(double _x,double _y, double _z);
00048
00049 Vector3d(){};
00050
00051
00052 Vector3d operator=(const Vector3d &v);
00053 Vector3d operator-=(const Vector3d &v);
00054 Vector3d operator+=(const Vector3d &v);
00055 Vector3d operator*=(const Vector3d &v);
00056 Vector3d operator/=(const Vector3d &v);
00057 Vector3d operator*=(double);
00058 Vector3d operator/=(double);
00059 Vector3d operator=(const Quaternion &q);
00060
00061
00062 Vector3d rotate(const Vector3d &v, double ang);
00063 double module(void);
00064
00065 double distToPlane(const Point3d &p, const Vector3d &n);
00066
00067 double distToLine(const Point3d &p, const Vector3d &d);
00068
00069 Vector3d normalized(void);
00070
00071 void normalize(void);
00072
00073
00074 string toString(void);
00075
00076
00077
00078
00079
00080 double X();
00081 double Y();
00082 double Z();
00083
00084
00085 friend class BoundingBox;
00086
00087 friend bool operator==(const Vector3d &a,const Vector3d &b);
00088 friend Vector3d operator^(const Vector3d &a,const Vector3d &b);
00089 friend double operator*(const Vector3d &a,const Vector3d &b);
00090 friend Vector3d operator-(const Vector3d &a,const Vector3d &b);
00091 friend Vector3d operator+(const Vector3d &a,const Vector3d &b);
00092
00093 friend Vector3d operator/(const Vector3d &a,double n);
00094 friend Vector3d operator*(const Vector3d &a,double n);
00095 friend Vector3d operator/(double n,const Vector3d &a);
00096 friend Vector3d operator*(double n,const Vector3d &a);
00097
00098 friend Vector3d operator-(const Vector3d &v);
00099
00100 friend Vector3d operator*(const Matrix3x3 &M, const Vector3d &v);
00101 friend Vector3d operator*(const Vector3d &v, const Matrix3x3 &M);
00102
00103 friend Quaternion operator*(const Vector3d &v, const Quaternion &q);
00104 friend Quaternion operator*(const Quaternion &q, const Vector3d &v);
00105 };
00106
00107 #include "vector3d.cc"
00108
00109 #endif