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
00041 #include <iostream.h>
00042
00043
00045
00046 #include "CP4D.h"
00047
00048
00050
00051
00052
00053
00054
00059 class CP3D
00060 {
00061 public:
00062 static double epsilon;
00063
00066 CP3D() { m_ard[0] = 0.0;
00067 m_ard[1] = 0.0;
00068 m_ard[2] = 0.0; };
00069
00072 CP3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00073 m_ard[1] = rdY;
00074 m_ard[2] = rdZ; }
00075
00078 CP3D(const CP3D& Point) { m_ard[0] = Point[0];
00079 m_ard[1] = Point[1];
00080 m_ard[2] = Point[2]; }
00081
00082
00084
00086
00089 operator CP4D() const;
00090
00092 const CP3D& operator=(const CP3D&);
00093
00098 int operator==(const CP3D&) const;
00099
00103 int operator!=(const CP3D&) const;
00104
00106 CP3D& operator+=(const CV3D&);
00107
00109 CP3D& operator-=(const CV3D&);
00110
00112 CP3D& operator*=(const CV3D&);
00113
00115 CP3D& operator*=(double);
00116
00118 CP3D& operator/=(double);
00119
00121 CP3D operator+(const CV3D&) const;
00122
00124 CP3D operator+(const CP3D&) const;
00125
00127 CP3D operator-(const CV3D&) const;
00128
00130 CV3D operator-(const CP3D&) const ;
00131
00133 CP3D operator*(const CV3D&) const;
00134
00136 CP3D operator*(double) const;
00137
00139 CP3D operator/(const CV3D&) const;
00140
00142 CP3D operator/(double) const;
00143
00147 double& operator [] (int i) { return m_ard[i]; };
00148
00150 double operator[](int i) const { return m_ard[i]; };
00151
00152
00154
00156
00158 double getMinComponent(void) const { return m_ard[getMinComponentCoord()]; };
00159
00161 double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00162
00164 double getMaxComponent(void) const { return m_ard[getMaxComponentCoord()]; };
00165
00167 double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00168
00170 int getMinComponentCoord(void) const;
00171
00173 int getAbsMinComponentCoord(void) const;
00174
00176 int getMaxComponentCoord(void) const;
00177
00179 int getAbsMaxComponentCoord(void) const;
00180
00184 CV3D getCV3D() const;
00185
00187 double getX(void) const { return m_ard[0]; };
00188
00190 double getY(void) const { return m_ard[1]; };
00191
00193 double getZ(void) const { return m_ard[2]; };
00194
00196 void setX(double rdX) { m_ard[0] = rdX; return; };
00197
00199 void setY(double rdY) { m_ard[1] = rdY; return; };
00200
00202 void setZ(double rdZ) { m_ard[2] = rdZ; return; };
00203
00206 void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00207 m_ard[1] = rdY;
00208 m_ard[2] = rdZ;
00209 return; };
00210
00212
00214
00216 friend CP3D AffinComb(const CP3D&, double, const CP3D&);
00217
00219 friend CP3D AffinComb3(double r, const CP3D& R,
00220 double s, const CP3D& S,
00221 double t, const CP3D T) {
00222 return CP3D(r*R[0] + s*S[0] + t*T[0],
00223 r*R[1] + s*S[1] + t*T[1],
00224 r*R[2] + s*S[2] + t*T[2]); };
00225
00227 friend double dist(const CP3D&, const CP3D&);
00228
00230 friend double quaddist(const CP3D&, const CP3D&);
00231
00233 friend CP3D Min(const CP3D&, const CP3D&);
00234
00236 friend CP3D Max(const CP3D&, const CP3D&);
00237
00239 friend CP3D operator*(double, const CP3D&);
00240
00242 friend CP3D MidPoint(const CP3D&, const CP3D&);
00243
00244
00245
00247
00248 void print() const;
00249
00251 friend inline ostream& operator<<(ostream&, const CP3D&);
00252
00254 friend inline istream& operator>>(istream&, CP3D&);
00255
00256 protected:
00257 double m_ard[3];
00258 };
00259
00260
00261
00262
00263
00264
00265
00266 inline const CP3D& CP3D::operator=(const CP3D& p1)
00267
00268 {
00269 m_ard[0] = p1.m_ard[0];
00270 m_ard[1] = p1.m_ard[1];
00271 m_ard[2] = p1.m_ard[2];
00272 return *this;
00273 }
00274
00275
00276
00277
00278
00279
00280
00281 inline CV3D CP3D::getCV3D() const
00282
00283 {
00284 return CV3D(m_ard[0], m_ard[1], m_ard[2]);
00285 }
00286
00287
00288
00289
00290
00291
00292
00293 inline ostream& operator<<(ostream& s, const CP3D& pnt)
00294
00295 {
00296 return s << "(" << pnt.m_ard[0] << "," << pnt.m_ard[1] << "," << pnt.m_ard[2] << ")";
00297 }
00298
00299
00300
00301
00302
00303
00304
00305 inline istream& operator>>(istream& s, CP3D& pnt)
00306
00307 {
00308 char c;
00309 return s >> c >> pnt.m_ard[0] >> c >> pnt.m_ard[1] >> c >> pnt.m_ard[2] >> c;
00310 }
00311
00312 #endif