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
00029
00030
00031
00032
00033
00034 #ifndef __CP3D_H
00035 #define __CP3D_H
00036
00037
00038
00040 #include <math.h>
00041 #ifdef _MSC_VER
00042 #if _MSC_VER >= 1300
00043 #include <iostream>
00044 #endif
00045 #else
00046 #include <iostream.h>
00047 #endif
00048
00049
00050
00052 #include "CV3D.h"
00053 #include "CP4D.h"
00054
00055
00057 class CV3D;
00058
00059
00060
00061
00066 class CP3D
00067 {
00068 public:
00069 static double epsilon;
00070
00073 CP3D() { m_ard[0] = 0.0;
00074 m_ard[1] = 0.0;
00075 m_ard[2] = 0.0; };
00076
00079 CP3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00080 m_ard[1] = rdY;
00081 m_ard[2] = rdZ; }
00082
00085 CP3D(const CP3D& Point) { m_ard[0] = Point[0];
00086 m_ard[1] = Point[1];
00087 m_ard[2] = Point[2]; }
00088
00089
00091
00093
00096 operator CP4D() const;
00097
00099 const CP3D& operator=(const CP3D&);
00100
00105 int operator==(const CP3D&) const;
00106
00110 int operator!=(const CP3D&) const;
00111
00113 CP3D& operator+=(const CV3D&);
00114
00116 CP3D& operator-=(const CV3D&);
00117
00119 CP3D& operator*=(const CV3D&);
00120
00122 CP3D& operator*=(double);
00123
00125 CP3D& operator/=(double);
00126
00128 CP3D operator+(const CV3D&) const;
00129
00131 CP3D operator+(const CP3D&) const;
00132
00134 CP3D operator-(const CV3D&) const;
00135
00137 CV3D operator-(const CP3D&) const ;
00138
00140 CP3D operator*(const CV3D&) const;
00141
00143 CP3D operator*(double) const;
00144
00146 CP3D operator/(const CV3D&) const;
00147
00149 CP3D operator/(double) const;
00150
00154 double& operator [] (int i) { return m_ard[i]; };
00155
00157 double operator[](int i) const { return m_ard[i]; };
00158
00159
00161
00163
00165 double getMinComponent(void) const { return m_ard[getMinComponentCoord()]; };
00166
00168 double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00169
00171 double getMaxComponent(void) const { return m_ard[getMaxComponentCoord()]; };
00172
00174 double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00175
00177 int getMinComponentCoord(void) const;
00178
00180 int getAbsMinComponentCoord(void) const;
00181
00183 int getMaxComponentCoord(void) const;
00184
00186 int getAbsMaxComponentCoord(void) const;
00187
00191 CV3D getCV3D() const;
00192
00194 double getX(void) const { return m_ard[0]; };
00195
00197 double getY(void) const { return m_ard[1]; };
00198
00200 double getZ(void) const { return m_ard[2]; };
00201
00203 void setX(double rdX) { m_ard[0] = rdX; return; };
00204
00206 void setY(double rdY) { m_ard[1] = rdY; return; };
00207
00209 void setZ(double rdZ) { m_ard[2] = rdZ; return; };
00210
00213 void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00214 m_ard[1] = rdY;
00215 m_ard[2] = rdZ;
00216 return; };
00217
00219
00221
00223 friend CP3D AffinComb(const CP3D&, double, const CP3D&);
00224
00226 friend CP3D AffinComb3(double r, const CP3D& R,
00227 double s, const CP3D& S,
00228 double t, const CP3D T) {
00229 return CP3D(r*R[0] + s*S[0] + t*T[0],
00230 r*R[1] + s*S[1] + t*T[1],
00231 r*R[2] + s*S[2] + t*T[2]); };
00232
00234 friend double dist(const CP3D&, const CP3D&);
00235
00237 friend double quaddist(const CP3D&, const CP3D&);
00238
00240 friend CP3D Min(const CP3D&, const CP3D&);
00241
00243 friend CP3D Max(const CP3D&, const CP3D&);
00244
00246 friend CP3D operator*(double, const CP3D&);
00247
00249 friend CP3D MidPoint(const CP3D&, const CP3D&);
00250
00251
00252
00254
00255 void print() const;
00256
00258 friend inline ostream& operator<<(ostream&, const CP3D&);
00259
00261 friend inline istream& operator>>(istream&, CP3D&);
00262
00263 protected:
00264 double m_ard[3];
00265 };
00266
00267
00268
00269
00270
00271
00272
00273 inline const CP3D& CP3D::operator=(const CP3D& p1)
00274
00275 {
00276 m_ard[0] = p1.m_ard[0];
00277 m_ard[1] = p1.m_ard[1];
00278 m_ard[2] = p1.m_ard[2];
00279 return *this;
00280 }
00281
00282
00283
00284
00285
00286
00287
00288 inline CV3D CP3D::getCV3D() const
00289
00290 {
00291 return CV3D(m_ard[0], m_ard[1], m_ard[2]);
00292 }
00293
00294
00295
00296
00297
00298
00299
00300 inline ostream& operator<<(ostream& s, const CP3D& pnt)
00301
00302 {
00303 return s << "(" << pnt.m_ard[0] << "," << pnt.m_ard[1] << "," << pnt.m_ard[2] << ")";
00304 }
00305
00306
00307
00308
00309
00310
00311
00312 inline istream& operator>>(istream& s, CP3D& pnt)
00313
00314 {
00315 char c;
00316 return s >> c >> pnt.m_ard[0] >> c >> pnt.m_ard[1] >> c >> pnt.m_ard[2] >> c;
00317 }
00318
00319 #endif