CV4D.h

Go to the documentation of this file.
00001 /*
00002  * CV4D.h
00003  * $Id: CV4D.h,v 1.4 2003/06/24 14:50:02 anxo Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Markus Janich, Michael Meissner, Rainer Jaeger
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 
00031 
00032 #ifndef __CV4D_H_
00033 #define __CV4D_H_
00034 
00035 
00036 // System
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 // Own
00050 
00051 
00052 // Forward declarations
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   // OVERLOADED OPERATORS //
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   // METHODS //
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 // Function   : operator=
00227 // Parameters : const CV4D& v
00228 // Purpose    : assign another vector to this vector
00229 // Comments   : 
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_

Generated on Tue Jul 11 10:42:56 2006 for QGLViewer by  doxygen 1.4.7