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 #ifndef __CP3D_H
00028 #define __CP3D_H
00029
00030
00031
00033
00034 #include <iostream.h>
00035
00036
00038
00039 #include "CP4D.h"
00040
00041
00043
00044
00045
00046
00047
00052 class CP3D
00053 {
00054 public:
00055 static double epsilon;
00056
00059 CP3D() { m_ard[0] = 0.0;
00060 m_ard[1] = 0.0;
00061 m_ard[2] = 0.0; };
00062
00065 CP3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00066 m_ard[1] = rdY;
00067 m_ard[2] = rdZ; }
00068
00071 CP3D(const CP3D& Point) { m_ard[0] = Point[0];
00072 m_ard[1] = Point[1];
00073 m_ard[2] = Point[2]; }
00074
00075
00077
00079
00082 operator CP4D() const;
00083
00085 const CP3D& operator=(const CP3D&);
00086
00091 int operator==(const CP3D&) const;
00092
00096 int operator!=(const CP3D&) const;
00097
00099 CP3D& operator+=(const CV3D&);
00100
00102 CP3D& operator-=(const CV3D&);
00103
00105 CP3D& operator*=(const CV3D&);
00106
00108 CP3D& operator*=(double);
00109
00111 CP3D& operator/=(double);
00112
00114 CP3D operator+(const CV3D&) const;
00115
00117 CP3D operator+(const CP3D&) const;
00118
00120 CP3D operator-(const CV3D&) const;
00121
00123 CV3D operator-(const CP3D&) const ;
00124
00126 CP3D operator*(const CV3D&) const;
00127
00129 CP3D operator*(double) const;
00130
00132 CP3D operator/(const CV3D&) const;
00133
00135 CP3D operator/(double) const;
00136
00140 double& operator [] (int i) { return m_ard[i]; };
00141
00143 double operator[](int i) const { return m_ard[i]; };
00144
00145
00147
00149
00151 double getMinComponent(void) const { return m_ard[getMinComponentCoord()]; };
00152
00154 double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00155
00157 double getMaxComponent(void) const { return m_ard[getMaxComponentCoord()]; };
00158
00160 double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00161
00163 int getMinComponentCoord(void) const;
00164
00166 int getAbsMinComponentCoord(void) const;
00167
00169 int getMaxComponentCoord(void) const;
00170
00172 int getAbsMaxComponentCoord(void) const;
00173
00177 CV3D getCV3D() const;
00178
00180 double getX(void) const { return m_ard[0]; };
00181
00183 double getY(void) const { return m_ard[1]; };
00184
00186 double getZ(void) const { return m_ard[2]; };
00187
00189 void setX(double rdX) { m_ard[0] = rdX; return; };
00190
00192 void setY(double rdY) { m_ard[1] = rdY; return; };
00193
00195 void setZ(double rdZ) { m_ard[2] = rdZ; return; };
00196
00199 void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00200 m_ard[1] = rdY;
00201 m_ard[2] = rdZ;
00202 return; };
00203
00205
00207
00209 friend CP3D AffinComb(const CP3D&, double, const CP3D&);
00210
00212 friend CP3D AffinComb3(double r, const CP3D& R,
00213 double s, const CP3D& S,
00214 double t, const CP3D T) {
00215 return CP3D(r*R[0] + s*S[0] + t*T[0],
00216 r*R[1] + s*S[1] + t*T[1],
00217 r*R[2] + s*S[2] + t*T[2]); };
00218
00220 friend double dist(const CP3D&, const CP3D&);
00221
00223 friend double quaddist(const CP3D&, const CP3D&);
00224
00226 friend CP3D Min(const CP3D&, const CP3D&);
00227
00229 friend CP3D Max(const CP3D&, const CP3D&);
00230
00232 friend CP3D operator*(double, const CP3D&);
00233
00235 friend CP3D MidPoint(const CP3D&, const CP3D&);
00236
00237
00238
00240
00241 void print() const;
00242
00244 friend inline ostream& operator<<(ostream&, const CP3D&);
00245
00247 friend inline istream& operator>>(istream&, CP3D&);
00248
00249 protected:
00250 double m_ard[3];
00251 };
00252
00253
00254
00255
00256
00257
00258
00259 inline const CP3D& CP3D::operator=(const CP3D& p1)
00260
00261 {
00262 m_ard[0] = p1.m_ard[0];
00263 m_ard[1] = p1.m_ard[1];
00264 m_ard[2] = p1.m_ard[2];
00265 return *this;
00266 }
00267
00268
00269
00270
00271
00272
00273
00274 inline CV3D CP3D::getCV3D() const
00275
00276 {
00277 return CV3D(m_ard[0], m_ard[1], m_ard[2]);
00278 }
00279
00280
00281
00282
00283
00284
00285
00286 inline ostream& operator<<(ostream& s, const CP3D& pnt)
00287
00288 {
00289 return s << "(" << pnt.m_ard[0] << "," << pnt.m_ard[1] << "," << pnt.m_ard[2] << ")";
00290 }
00291
00292
00293
00294
00295
00296
00297
00298 inline istream& operator>>(istream& s, CP3D& pnt)
00299
00300 {
00301 char c;
00302 return s >> c >> pnt.m_ard[0] >> c >> pnt.m_ard[1] >> c >> pnt.m_ard[2] >> c;
00303 }
00304
00305 #endif