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 __CP2D_H
00035 #define __CP2D_H
00036
00037
00038
00040
00041 #include <iostream.h>
00042
00043
00045
00046 #include "CP3D.h"
00047
00048
00049
00051
00052
00053
00054
00055
00060 class CP2D
00061 {
00062 public:
00063 static double epsilon;
00064
00067 CP2D() { m_ard[0] = 0.0;
00068 m_ard[1] = 0.0; };
00069
00072 CP2D(double rdX, double rdY) { m_ard[0] = rdX;
00073 m_ard[1] = rdY; }
00074
00077 CP2D(const CP2D& Point) { m_ard[0] = Point[0];
00078 m_ard[1] = Point[1]; }
00079
00080
00082
00084
00087 operator CP3D() const;
00088
00090 const CP2D& operator=(const CP2D&);
00091
00096 int operator==(const CP2D&) const;
00097
00101 int operator!=(const CP2D&) const;
00102
00104 CP2D& operator+=(const CV2D&);
00105
00107 CP2D& operator-=(const CV2D&);
00108
00110 CP2D& operator*=(const CV2D&);
00111
00113 CP2D& operator*=(double);
00114
00116 CP2D& operator/=(double);
00117
00119 CP2D operator+(const CV2D&) const;
00120
00122 CP2D operator+(const CP2D&) const;
00123
00125 CP2D operator-(const CV2D&) const;
00126
00128 CV2D operator-(const CP2D&) const ;
00129
00131 CP2D operator*(const CV2D&) const;
00132
00134 CP2D operator*(double) const;
00135
00137 CP2D operator/(const CV2D&) const;
00138
00140 CP2D operator/(double) const;
00141
00145 double& operator [] (int i) { return m_ard[i]; };
00146
00148 double operator[](int i) const { return m_ard[i]; };
00149
00150
00152
00154
00156 double getMinComponent(void) const { return m_ard[getMinComponentCoord()]; };
00157
00159 double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00160
00162 double getMaxComponent(void) const { return m_ard[getMaxComponentCoord()]; };
00163
00165 double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00166
00168 int getMinComponentCoord(void) const;
00169
00171 int getAbsMinComponentCoord(void) const;
00172
00174 int getMaxComponentCoord(void) const;
00175
00177 int getAbsMaxComponentCoord(void) const;
00178
00182 CV2D getCV2D() const;
00183
00185 double getX(void) const { return m_ard[0]; };
00186
00188 double getY(void) const { return m_ard[1]; };
00189
00191 void setX(double rdX) { m_ard[0] = rdX; return; };
00192
00194 void setY(double rdY) { m_ard[1] = rdY; return; };
00195
00198 void setCoord(double rdX, double rdY) { m_ard[0] = rdX;
00199 m_ard[1] = rdY;
00200 return; };
00201
00203
00205
00207 friend CP2D AffinComb(const CP2D&, double, const CP2D&);
00208
00210 friend CP2D AffinComb2(double r, const CP2D& R,
00211 double s, const CP2D& S) {
00212 return CP2D(r*R[0] + s*S[0],
00213 r*R[1] + s*S[1]); };
00214
00216 friend double dist(const CP2D&, const CP2D&);
00217
00219 friend double quaddist(const CP2D&, const CP2D&);
00220
00222 friend CP2D Min(const CP2D&, const CP2D&);
00223
00225 friend CP2D Max(const CP2D&, const CP2D&);
00226
00228 friend CP2D operator*(double, const CP2D&);
00229
00231 friend CP2D MidPoint(const CP2D&, const CP2D&);
00232
00233
00234
00236
00237 void print() const;
00238
00240 friend inline ostream& operator<<(ostream&, const CP2D&);
00241
00243 friend inline istream& operator>>(istream&, CP2D&);
00244
00245
00246 protected:
00247 double m_ard[2];
00248 };
00249
00250
00251
00252
00253
00254
00255
00256 inline const CP2D& CP2D::operator=(const CP2D& p1)
00257
00258 {
00259 m_ard[0] = p1.m_ard[0];
00260 m_ard[1] = p1.m_ard[1];
00261 return *this;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270 inline CV2D CP2D::getCV2D() const
00271
00272 {
00273 return CV2D(m_ard[0], m_ard[1]);
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 inline ostream& operator<<(ostream& s, const CP2D& pnt)
00283
00284 {
00285 return s << "(" << pnt.m_ard[0] << "," << pnt.m_ard[1] << ")";
00286 }
00287
00288
00289
00290
00291
00292
00293
00294 inline istream& operator>>(istream& s, CP2D& pnt)
00295
00296 {
00297 char c;
00298 return s >> c >> pnt.m_ard[0] >> c >> pnt.m_ard[1] >> c;
00299 }
00300
00301 #endif