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 #ifndef __CP4D_H
00032 #define __CP4D_H
00033
00034
00035
00036
00038 #include <math.h>
00039 #ifdef _MSC_VER
00040 #if _MSC_VER >= 1300
00041 #include <iostream>
00042 #endif
00043 #else
00044 #include <iostream.h>
00045 #endif
00046
00047
00049 #include "CV4D.h"
00050
00051
00053 class CP3D;
00054
00055
00060 class CP4D {
00061 public:
00062 static double epsilon;
00063
00066 CP4D() { m_ard[0] = 0.0;
00067 m_ard[1] = 0.0;
00068 m_ard[2] = 0.0;
00069 m_ard[3] = 0.0; };
00070
00073 CP4D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00074 m_ard[1] = rdY;
00075 m_ard[2] = rdZ;
00076 m_ard[3] = 1; };
00077
00080 CP4D(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX;
00081 m_ard[1] = rdY;
00082 m_ard[2] = rdZ;
00083 m_ard[3] = rdW; };
00084
00087 CP4D(const CP4D& Point) { m_ard[0] = Point[0];
00088 m_ard[1] = Point[1];
00089 m_ard[2] = Point[2];
00090 m_ard[3] = Point[3]; };
00091
00092
00093
00095
00097
00100 operator CP3D() const;
00101
00103 const CP4D& operator=(const CP4D&);
00104
00109 int operator==(const CP4D&);
00110
00114 int operator!=(const CP4D&);
00115
00117 CP4D& operator+=(const CV4D&);
00118
00120 CP4D& operator-=(const CV4D&);
00121
00123 CV4D operator-(const CP4D&) const;
00124
00126 CP4D operator+(const CV4D&) const;
00127
00129 CP4D operator-(const CV4D&) const;
00130
00132 CP4D operator-() const;
00133
00137 double& operator[](int i) { return m_ard[i]; };
00138
00140 double operator[](int i) const { return m_ard[i]; };
00141
00142
00143
00145
00147
00151 CV4D getCV4D() const;
00152
00154 double getX() const { return m_ard[0]; };
00155
00157 double getY() const { return m_ard[1]; };
00158
00160 double getZ() const { return m_ard[2]; };
00161
00163 double getW() const { return m_ard[3]; };
00164
00166 void setX(double rdX) { m_ard[0] = rdX; };
00167
00169 void setY(double rdY) { m_ard[1] = rdY; };
00170
00172 void setZ(double rdZ) { m_ard[2] = rdZ; };
00173
00175 void setW(double rdW) { m_ard[3] = rdW; };
00176
00179 void setCoord(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX;
00180 m_ard[1] = rdY;
00181 m_ard[2] = rdZ;
00182 m_ard[3] = rdW;
00183 return; };
00184
00186 void print() const;
00187
00188
00189
00191
00193
00195 friend ostream& operator<<(ostream&, const CP4D&);
00196
00198 friend istream& operator>>(istream&, CP4D&);
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00210 friend inline CP4D AffinComb3(double, const CP4D&,
00211 double, const CP4D&,
00212 double, const CP4D&);
00213
00214
00215 private:
00216 friend class CP3D;
00217
00218 protected:
00219 double m_ard[4];
00220 };
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 inline const CP4D& CP4D::operator=(const CP4D& cPoint) {
00231
00232 m_ard[0] = cPoint.m_ard[0];
00233 m_ard[1] = cPoint.m_ard[1];
00234 m_ard[2] = cPoint.m_ard[2];
00235 m_ard[3] = cPoint.m_ard[3];
00236
00237 return *this;
00238 }
00239
00240
00241
00242
00243
00244
00245
00246 inline CV4D CP4D::getCV4D() const
00247
00248 {
00249 return CV4D(m_ard[0], m_ard[1], m_ard[2], m_ard[3]);
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259 inline CP4D AffinComb3(double r, const CP4D& R, double s, const CP4D& S,
00260 double t, const CP4D &T)
00261
00262 {
00263 return CP4D(r*R[0] + s*S[0] + t*T[0],
00264 r*R[1] + s*S[1] + t*T[1],
00265 r*R[2] + s*S[2] + t*T[2],
00266 r*R[3] + s*S[3] + t*T[3]);
00267 }
00268
00269 #endif