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 __CV4D_H_
00033
#define __CV4D_H_
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
00048
00050
00051
00052
00054
class CV3D;
00055
00056
using namespace std;
00057
00063 class CV4D {
00064
public:
00065
static double epsilon;
00066
00070 CV4D() {
m_ard[0] = 0.0;
00071
m_ard[1] = 0.0;
00072
m_ard[2] = 0.0;
00073
m_ard[3] = 0.0; };
00074
00075
00078 CV4D(
double rdX,
double rdY,
double rdZ) {
m_ard[0] = rdX;
00079
m_ard[1] = rdY;
00080
m_ard[2] = rdZ;
00081
m_ard[3] = 1.0; };
00082
00085 CV4D(
double rdX,
double rdY,
double rdZ,
double rdW) {
m_ard[0] = rdX;
00086
m_ard[1] = rdY;
00087
m_ard[2] = rdZ;
00088
m_ard[3] = rdW; };
00089
00092 CV4D(
const CV4D& Vector) {
m_ard[0] = Vector.
m_ard[0];
00093
m_ard[1] = Vector.
m_ard[1];
00094
m_ard[2] = Vector.
m_ard[2];
00095
m_ard[3] = Vector.
m_ard[3]; };
00096
00097
00098
00100
00102
00105
operator CV3D() const;
00106
00108 const
CV4D& operator=(const
CV4D&);
00109
00113
bool operator==(const CV4D&) const;
00114
00118
bool operator!=(const CV4D&) const;
00119
00121 CV4D& operator+=(const CV4D&);
00122
00124 CV4D& operator-=(const CV4D&);
00125
00127 CV4D operator+(const CV4D&) const;
00128
00130 CV4D operator-(const CV4D&) const;
00131
00133 CV4D operator-() const;
00134
00136
double operator*(const CV4D&) const;
00137
00139 CV4D operator*(
double) const;
00140
00142 CV4D operator/(
double);
00143
00148 CV4D operator|(const CV4D&) const;
00149
00153 double& operator[](
int i) {
return m_ard[i]; };
00154
00156 double operator[](
int i)
const {
return m_ard[i]; };
00157
00159
friend CV4D operator*(
double,
const CV4D&);
00160
00161
00162
00164
00166
00168 double getX()
const {
return m_ard[0]; };
00169
00171 double getY()
const {
return m_ard[1]; };
00172
00174 double getZ()
const {
return m_ard[2]; };
00175
00177 double getW()
const {
return m_ard[3]; };
00178
00180 void setX(
double rdX) {
m_ard[0] = rdX; };
00181
00183 void setY(
double rdY) {
m_ard[1] = rdY; };
00184
00186 void setZ(
double rdZ) {
m_ard[2] = rdZ; };
00187
00189 void setW(
double rdW) {
m_ard[3] = rdW; };
00190
00193 void setCoord(
double rdX,
double rdY,
double rdZ,
double rdW) {
m_ard[0] = rdX;
00194
m_ard[1] = rdY;
00195
m_ard[2] = rdZ;
00196
m_ard[3] = rdW;
00197
return; };
00198
00200
double getNorm() const;
00201
00203
void normalize();
00204
00206
CV4D getNormalized() const;
00207
00209
void print() const;
00210
00212 friend ostream& operator<<(ostream&, const
CV4D&);
00213
00215 friend istream& operator>>(istream&, CV4D&);
00216
00217
00218
00219 protected:
00220 double m_ard[4];
00221
00222 };
00223
00224
00225
00226
00227
00228
00229
00230 inline const CV4D& CV4D::operator=(const CV4D& v)
00231
00232 {
00233 m_ard[0] = v.m_ard[0];
00234 m_ard[1] = v.m_ard[1];
00235 m_ard[2] = v.m_ard[2];
00236 m_ard[3] = v.m_ard[3];
00237
00238
return *
this;
00239 }
00240
00241
#endif // __CV4D_H_