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 #ifndef __CV2D_H
00033 #define __CV2D_H
00034
00035
00036
00037
00039 #include <math.h>
00040 #ifdef _MSC_VER
00041 #if _MSC_VER >= 1300
00042 #include <iostream>
00043 #endif
00044 #else
00045 #include <iostream.h>
00046 #endif
00047
00048
00049
00051
00052
00053
00055 class CV3D;
00056
00057 using namespace std;
00058
00064 class CV2D {
00065 public:
00066 static double epsilon;
00067
00070 CV2D(void) { m_ard[0] = 0.0;
00071 m_ard[1] = 0.0; };
00072
00075 CV2D(double rdX, double rdY) { m_ard[0] = rdX;
00076 m_ard[1] = rdY; };
00077
00080 CV2D(const CV2D& Vector) { m_ard[0] = Vector.m_ard[0];
00081 m_ard[1] = Vector.m_ard[1]; };
00082
00084 ~CV2D(void) {};
00085
00086
00087
00089
00091
00095 operator CV3D() const;
00096
00098 const CV2D& operator=(const CV2D&);
00099
00103 bool operator==(const CV2D&) const;
00104
00108 bool operator!=(const CV2D&) const;
00109
00111 CV2D& operator+=(const CV2D&);
00112
00114 CV2D& operator-=(const CV2D&);
00115
00117 CV2D& operator*=(double);
00118
00120 CV2D& operator/=(double);
00121
00123 CV2D operator+(const CV2D&) const;
00124
00126 CV2D operator-(const CV2D&) const;
00127
00129 CV2D operator-(void) const;
00130
00132 double operator*(const CV2D&) const;
00133
00135 CV2D operator*(double) const;
00136
00138 CV2D operator/(double) const;
00139
00143 double& operator[](int i) { return m_ard[i]; };
00144
00146 double operator[](int i) const { return m_ard[i]; };
00147
00149 friend CV2D operator*(double, const CV2D&);
00150
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
00182 double getX(void) const { return m_ard[0]; };
00183
00185 double getY(void) const { return m_ard[1]; };
00186
00188 void setX(double rdX) { m_ard[0] = rdX; };
00189
00191 void setY(double rdY) { m_ard[1] = rdY; };
00192
00195 void setCoord(double rdX, double rdY) { m_ard[0] = rdX;
00196 m_ard[1] = rdY;
00197 return; };
00198
00200 double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1]); };
00201
00203 void normalize(void);
00204
00206 CV2D getNormalized(void) const;
00207
00209 void print(void) const;
00210
00212 friend ostream& operator<<(ostream&, const CV2D&);
00213
00215 friend istream& operator>>(istream&, CV2D&);
00216
00217
00218 protected:
00219 double m_ard[2];
00220
00221 };
00222
00223
00224
00225
00226
00227
00228
00229 inline const CV2D& CV2D::operator=(const CV2D& v)
00230
00231 {
00232 m_ard[0] = v[0];
00233 m_ard[1] = v[1];
00234 return *this;
00235 }
00236
00237 #endif // _CV2D_H_