00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef Rn__h
00029 #define Rn__h
00030
00031 #include <gp_Pnt.hxx>
00032 #include <gp_Vec.hxx>
00033 #include <gp_Dir.hxx>
00034
00035
00036
00037
00038
00039
00040
00041 #include <iostream>
00042 #include <cmath>
00043
00044
00045 template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
00046 template<class T> inline void Echange (T& a,T& b) {T c=a;a=b;b=c;}
00047
00048 template<class T> inline T Min (const T &a,const T &b) {return a < b ? a : b;}
00049 template<class T> inline T Max (const T &a,const T & b) {return a > b ? a : b;}
00050
00051 template<class T> inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);}
00052 template<class T> inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);}
00053
00054 template<class T> inline T Max (const T &a,const T & b,const T & c,const T & d)
00055 {return Max(Max(a,b),Max(c,d));}
00056 template<class T> inline T Min (const T &a,const T & b,const T & c,const T & d)
00057 {return Min(Min(a,b),Min(c,d));}
00058
00059
00060
00061 typedef char Nom[1+24];
00062
00063
00064
00065 #ifndef PCLINUX64
00066 typedef unsigned long int N;
00067 #else
00068 typedef unsigned int N;
00069 #endif
00070
00071
00072
00073 #ifndef PCLINUX64
00074 typedef long int Z;
00075 #else
00076 typedef int Z;
00077 #endif
00078
00079
00080
00081 typedef double R;
00082
00083
00084
00085
00086
00087
00088
00089 class R2
00090 {
00091 friend std::ostream& operator << (std::ostream& f, const R2 & P)
00092 { f << P.x << ' ' << P.y ; return f; }
00093 friend std::istream& operator >> (std::istream& f, R2 & P)
00094 { f >> P.x >> P.y ; return f; }
00095
00096 friend std::ostream& operator << (std::ostream& f, const R2 * P)
00097 { f << P->x << ' ' << P->y ; return f; }
00098 friend std::istream& operator >> (std::istream& f, R2 * P)
00099 { f >> P->x >> P->y ; return f; }
00100
00101 public:
00102 R x,y;
00103
00104 R2 () :x(0),y(0) {}
00105 R2 (R a,R b) :x(a),y(b) {}
00106 R2 (R2 A,R2 B) :x(B.x-A.x),y(B.y-A.y) {}
00107
00108 R2 operator+(R2 P) const {return R2(x+P.x,y+P.y);}
00109 R2 operator+=(R2 P) {x += P.x;y += P.y; return *this;}
00110 R2 operator-(R2 P) const {return R2(x-P.x,y-P.y);}
00111 R2 operator-=(R2 P) {x -= P.x;y -= P.y; return *this;}
00112 R2 operator-()const {return R2(-x,-y);}
00113 R2 operator+()const {return *this;}
00114 R operator,(R2 P)const {return x*P.x+y*P.y;}
00115 R operator^(R2 P)const {return x*P.y-y*P.x;}
00116 R2 operator*(R c)const {return R2(x*c,y*c);}
00117 R2 operator*=(R c) {x *= c; y *= c; return *this;}
00118 R2 operator/(R c)const {return R2(x/c,y/c);}
00119 R2 operator/=(R c) {x /= c; y /= c; return *this;}
00120 R & operator[](int i) {return (&x)[i];}
00121 R2 orthogonal() {return R2(-y,x);}
00122 friend R2 operator*(R c,R2 P) {return P*c;}
00123 };
00124
00125
00126
00127
00128 class R3
00129 {
00130 friend std::ostream& operator << (std::ostream& f, const R3 & P)
00131 { f << P.x << ' ' << P.y << ' ' << P.z ; return f; }
00132 friend std::istream& operator >> (std::istream& f, R3 & P)
00133 { f >> P.x >> P.y >> P.z ; return f; }
00134
00135 friend std::ostream& operator << (std::ostream& f, const R3 * P)
00136 { f << P->x << ' ' << P->y << ' ' << P->z ; return f; }
00137 friend std::istream& operator >> (std::istream& f, R3 * P)
00138 { f >> P->x >> P->y >> P->z ; return f; }
00139
00140 public:
00141 R x,y,z;
00142
00143 R3 () :x(0),y(0),z(0) {}
00144 R3 (R a,R b,R c):x(a),y(b),z(c) {}
00145 R3 (R3 A,R3 B):x(B.x-A.x),y(B.y-A.y),z(B.z-A.z) {}
00146
00147 R3 (gp_Pnt P) : x(P.X()), y(P.Y()), z(P.Z()) {}
00148 R3 (gp_Vec V) : x(V.X()), y(V.Y()), z(V.Z()) {}
00149 R3 (gp_Dir P) : x(P.X()), y(P.Y()), z(P.Z()) {}
00150
00151 R3 operator+(R3 P)const {return R3(x+P.x,y+P.y,z+P.z);}
00152 R3 operator+=(R3 P) {x += P.x; y += P.y; z += P.z; return *this;}
00153 R3 operator-(R3 P)const {return R3(x-P.x,y-P.y,z-P.z);}
00154 R3 operator-=(R3 P) {x -= P.x; y -= P.y; z -= P.z; return *this;}
00155 R3 operator-()const {return R3(-x,-y,-z);}
00156 R3 operator+()const {return *this;}
00157 R operator,(R3 P)const {return x*P.x+y*P.y+z*P.z;}
00158 R3 operator^(R3 P)const {return R3(y*P.z-z*P.y ,P.x*z-x*P.z, x*P.y-y*P.x);}
00159 R3 operator*(R c)const {return R3(x*c,y*c,z*c);}
00160 R3 operator*=(R c) {x *= c; y *= c; z *= c; return *this;}
00161 R3 operator/(R c)const {return R3(x/c,y/c,z/c);}
00162 R3 operator/=(R c) {x /= c; y /= c; z /= c; return *this;}
00163 R & operator[](int i) {return (&x)[i];}
00164 friend R3 operator*(R c,R3 P) {return P*c;}
00165
00166 R3 operator=(gp_Pnt P) {return R3(P.X(),P.Y(),P.Z());}
00167 R3 operator=(gp_Dir P) {return R3(P.X(),P.Y(),P.Z());}
00168
00169 friend gp_Pnt gp_pnt(R3 xyz) { return gp_Pnt(xyz.x,xyz.y,xyz.z); }
00170
00171 friend gp_Dir gp_dir(R3 xyz) { return gp_Dir(xyz.x,xyz.y,xyz.z); }
00172
00173 bool DansPave( R3 & xyzMin, R3 & xyzMax )
00174 { return xyzMin.x<=x && x<=xyzMax.x &&
00175 xyzMin.y<=y && y<=xyzMax.y &&
00176 xyzMin.z<=z && z<=xyzMax.z; }
00177 };
00178
00179
00180
00181 class R4: public R3
00182 {
00183 friend std::ostream& operator <<(std::ostream& f, const R4 & P )
00184 { f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; }
00185 friend istream& operator >>(istream& f, R4 & P)
00186 { f >> P.x >> P.y >> P.z >> P.omega ; return f; }
00187
00188 friend std::ostream& operator <<(std::ostream& f, const R4 * P )
00189 { f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; }
00190 friend istream& operator >>(istream& f, R4 * P)
00191 { f >> P->x >> P->y >> P->z >> P->omega ; return f; }
00192
00193 public:
00194 R omega;
00195
00196 R4 () :omega(1.0) {}
00197 R4 (R a,R b,R c,R d):R3(a,b,c),omega(d) {}
00198 R4 (R4 A,R4 B) :R3(B.x-A.x,B.y-A.y,B.z-A.z),omega(B.omega-A.omega) {}
00199
00200 R4 operator+(R4 P)const {return R4(x+P.x,y+P.y,z+P.z,omega+P.omega);}
00201 R4 operator+=(R4 P) {x += P.x;y += P.y;z += P.z;omega += P.omega;return *this;}
00202 R4 operator-(R4 P)const {return R4(x-P.x,y-P.y,z-P.z,omega-P.omega);}
00203 R4 operator-=(R4 P) {x -= P.x;y -= P.y;z -= P.z;omega -= P.omega;return *this;}
00204 R4 operator-()const {return R4(-x,-y,-z,-omega);}
00205 R4 operator+()const {return *this;}
00206 R operator,(R4 P)const {return x*P.x+y*P.y+z*P.z+omega*P.omega;}
00207 R4 operator*(R c)const {return R4(x*c,y*c,z*c,omega*c);}
00208 R4 operator*=(R c) {x *= c; y *= c; z *= c; omega *= c; return *this;}
00209 R4 operator/(R c)const {return R4(x/c,y/c,z/c,omega/c);}
00210 R4 operator/=(R c) {x /= c; y /= c; z /= c; omega /= c; return *this;}
00211 R & operator[](int i) {return (&x)[i];}
00212 friend R4 operator*(R c,R4 P) {return P*c;}
00213 };
00214
00215
00216
00217 inline R Aire2d(const R2 A,const R2 B,const R2 C){return (B-A)^(C-A);}
00218 inline R Angle2d(R2 P){ return atan2(P.y,P.x);}
00219
00220 inline R Norme2_2(const R2 & A){ return (A,A);}
00221 inline R Norme2(const R2 & A){ return sqrt((A,A));}
00222 inline R NormeInfinie(const R2 & A){return Max(Abs(A.x),Abs(A.y));}
00223
00224 inline R Norme2_2(const R3 & A){ return (A,A);}
00225 inline R Norme2(const R3 & A){ return sqrt((A,A));}
00226 inline R NormeInfinie(const R3 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z));}
00227
00228 inline R Norme2_2(const R4 & A){ return (A,A);}
00229 inline R Norme2(const R4 & A){ return sqrt((A,A));}
00230 inline R NormeInfinie(const R4 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z),Abs(A.omega));}
00231
00232 inline R2 XY(R3 P) {return R2(P.x, P.y);}
00233 inline R3 Min(R3 P, R3 Q)
00234 {return R3(P.x<Q.x ? P.x : Q.x, P.y<Q.y ? P.y : Q.y, P.z<Q.z ? P.z : Q.z);}
00235 inline R3 Max(R3 P, R3 Q)
00236 {return R3(P.x>Q.x ? P.x : Q.x, P.y>Q.y ? P.y : Q.y, P.z>Q.z ? P.z : Q.z);}
00237
00238 #endif