00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXVEC3D_H
00025 #define FXVEC3D_H
00026
00027
00028 namespace FX {
00029
00030
00031
00032 class FXAPI FXVec3d {
00033 public:
00034 FXdouble x;
00035 FXdouble y;
00036 FXdouble z;
00037 public:
00038
00039
00040 FXVec3d(){}
00041
00042
00043 FXVec3d(const FXVec3d& v){x=v.x;y=v.y;z=v.z;}
00044
00045
00046 FXVec3d(const FXdouble v[]){x=v[0];y=v[1];z=v[2];}
00047
00048
00049 FXVec3d(FXdouble xx,FXdouble yy,FXdouble zz=1.0){x=xx;y=yy;z=zz;}
00050
00051
00052 FXVec3d(FXColor color);
00053
00054
00055 FXdouble& operator[](FXint i){return (&x)[i];}
00056
00057
00058 const FXdouble& operator[](FXint i) const {return (&x)[i];}
00059
00060
00061 FXVec3d& operator=(FXColor color);
00062
00063
00064 FXVec3d& operator=(const FXVec3d& v){x=v.x;y=v.y;z=v.z;return *this;}
00065
00066
00067 FXVec3d& operator=(const FXdouble v[]){x=v[0];y=v[1];z=v[2];return *this;}
00068
00069
00070 FXVec3d& operator*=(FXdouble n){x*=n;y*=n;z*=n;return *this;}
00071 FXVec3d& operator/=(FXdouble n){x/=n;y/=n;z/=n;return *this;}
00072 FXVec3d& operator+=(const FXVec3d& v){x+=v.x;y+=v.y;z+=v.z;return *this;}
00073 FXVec3d& operator-=(const FXVec3d& v){x-=v.x;y-=v.y;z-=v.z;return *this;}
00074
00075
00076 operator FXdouble*(){return &x;}
00077 operator const FXdouble*() const {return &x;}
00078 operator FXVec2d&(){return *reinterpret_cast<FXVec2d*>(this);}
00079 operator const FXVec2d&() const {return *reinterpret_cast<const FXVec2d*>(this);}
00080
00081
00082 operator FXColor() const;
00083
00084
00085 friend FXAPI FXVec3d operator+(const FXVec3d& v){return v;}
00086 friend FXAPI FXVec3d operator-(const FXVec3d& v){return FXVec3d(-v.x,-v.y,-v.z);}
00087
00088
00089 friend FXAPI FXVec3d operator+(const FXVec3d& a,const FXVec3d& b){return FXVec3d(a.x+b.x,a.y+b.y,a.z+b.z);}
00090 friend FXAPI FXVec3d operator-(const FXVec3d& a,const FXVec3d& b){return FXVec3d(a.x-b.x,a.y-b.y,a.z-b.z);}
00091
00092
00093 friend FXAPI FXVec3d operator*(const FXVec3d& a,FXdouble n){return FXVec3d(a.x*n,a.y*n,a.z*n);}
00094 friend FXAPI FXVec3d operator*(FXdouble n,const FXVec3d& a){return FXVec3d(n*a.x,n*a.y,n*a.z);}
00095 friend FXAPI FXVec3d operator/(const FXVec3d& a,FXdouble n){return FXVec3d(a.x/n,a.y/n,a.z/n);}
00096 friend FXAPI FXVec3d operator/(FXdouble n,const FXVec3d& a){return FXVec3d(n/a.x,n/a.y,n/a.z);}
00097
00098
00099 friend FXAPI FXdouble operator*(const FXVec3d& a,const FXVec3d& b){return a.x*b.x+a.y*b.y+a.z*b.z;}
00100 friend FXAPI FXVec3d operator^(const FXVec3d& a,const FXVec3d& b){return FXVec3d(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);}
00101
00102
00103 friend FXAPI int operator!(const FXVec3d& a){return a.x==0.0 && a.y==0.0 && a.z==0.0;}
00104
00105
00106 friend FXAPI int operator==(const FXVec3d& a,const FXVec3d& b){return a.x==b.x && a.y==b.y && a.z==b.z;}
00107 friend FXAPI int operator!=(const FXVec3d& a,const FXVec3d& b){return a.x!=b.x || a.y!=b.y || a.z!=b.z;}
00108
00109 friend FXAPI int operator==(const FXVec3d& a,FXdouble n){return a.x==n && a.y==n && a.z==n;}
00110 friend FXAPI int operator!=(const FXVec3d& a,FXdouble n){return a.x!=n || a.y!=n || a.z!=n;}
00111
00112 friend FXAPI int operator==(FXdouble n,const FXVec3d& a){return n==a.x && n==a.y && n==a.z;}
00113 friend FXAPI int operator!=(FXdouble n,const FXVec3d& a){return n!=a.x || n!=a.y || n!=a.z;}
00114
00115
00116 friend FXAPI int operator<(const FXVec3d& a,const FXVec3d& b){return a.x<b.x && a.y<b.y && a.z<b.z;}
00117 friend FXAPI int operator<=(const FXVec3d& a,const FXVec3d& b){return a.x<=b.x && a.y<=b.y && a.z<=b.z;}
00118 friend FXAPI int operator>(const FXVec3d& a,const FXVec3d& b){return a.x>b.x && a.y>b.y && a.z>b.z;}
00119 friend FXAPI int operator>=(const FXVec3d& a,const FXVec3d& b){return a.x>=b.x && a.y>=b.y && a.z>=b.z;}
00120
00121 friend FXAPI int operator<(const FXVec3d& a,FXdouble n){return a.x<n && a.y<n && a.z<n;}
00122 friend FXAPI int operator<=(const FXVec3d& a,FXdouble n){return a.x<=n && a.y<=n && a.z<=n;}
00123 friend FXAPI int operator>(const FXVec3d& a,FXdouble n){return a.x>n && a.y>n && a.z>n;}
00124 friend FXAPI int operator>=(const FXVec3d& a,FXdouble n){return a.x>=n && a.y>=n && a.z>=n;}
00125
00126 friend FXAPI int operator<(FXdouble n,const FXVec3d& a){return n<a.x && n<a.y && n<a.z;}
00127 friend FXAPI int operator<=(FXdouble n,const FXVec3d& a){return n<=a.x && n<=a.y && n<=a.z;}
00128 friend FXAPI int operator>(FXdouble n,const FXVec3d& a){return n>a.x && n>a.y && n>a.z;}
00129 friend FXAPI int operator>=(FXdouble n,const FXVec3d& a){return n>=a.x && n>=a.y && n>=a.z;}
00130
00131
00132 friend FXAPI FXdouble len2(const FXVec3d& a){ return a.x*a.x+a.y*a.y+a.z*a.z; }
00133 friend FXAPI FXdouble len(const FXVec3d& a){ return sqrt(len2(a)); }
00134
00135
00136 friend FXAPI FXVec3d normalize(const FXVec3d& a);
00137
00138
00139 friend FXAPI FXVec3d lo(const FXVec3d& a,const FXVec3d& b){return FXVec3d(FXMIN(a.x,b.x),FXMIN(a.y,b.y),FXMIN(a.z,b.z));}
00140 friend FXAPI FXVec3d hi(const FXVec3d& a,const FXVec3d& b){return FXVec3d(FXMAX(a.x,b.x),FXMAX(a.y,b.y),FXMAX(a.z,b.z));}
00141
00142
00143 friend FXAPI FXStream& operator<<(FXStream& store,const FXVec3d& v);
00144
00145
00146 friend FXAPI FXStream& operator>>(FXStream& store,FXVec3d& v);
00147 };
00148
00149 }
00150
00151 #endif