Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CV4D.h

Go to the documentation of this file.
00001 /*
00002  * CV4D.h
00003  * $Id: CV4D.h,v 1.3 2001/11/15 16:54:52 guenth 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 #include <iostream.h>
00040 
00041 
00042 // Own
00044 
00045 
00046 // Forward declarations
00048 class CV3D;
00049 
00050 
00051 
00057 class CV4D {
00058 public:
00059   static double epsilon;
00060 
00064   CV4D() { m_ard[0] = 0.0;
00065            m_ard[1] = 0.0;
00066            m_ard[2] = 0.0;
00067            m_ard[3] = 0.0; };
00068 
00069 
00072   CV4D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 
00073                                              m_ard[1] = rdY; 
00074                                              m_ard[2] = rdZ;
00075                                              m_ard[3] = 1.0; };
00076 
00079   CV4D(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00080                                                          m_ard[1] = rdY; 
00081                                                          m_ard[2] = rdZ;
00082                                                          m_ard[3] = rdW; };
00083 
00086   CV4D(const CV4D& Vector) { m_ard[0] = Vector.m_ard[0];
00087                              m_ard[1] = Vector.m_ard[1];
00088                              m_ard[2] = Vector.m_ard[2];
00089                              m_ard[3] = Vector.m_ard[3]; };
00090 
00091 
00092 
00094   // OVERLOADED OPERATORS //
00096 
00099   operator CV3D() const;
00100 
00102   const CV4D& operator=(const CV4D&);
00103 
00107   bool operator==(const CV4D&) const;
00108 
00112   bool operator!=(const CV4D&) const;
00113 
00115   CV4D& operator+=(const CV4D&);
00116 
00118   CV4D& operator-=(const CV4D&);
00119 
00121   CV4D operator+(const CV4D&) const;
00122 
00124   CV4D operator-(const CV4D&) const;
00125 
00127   CV4D operator-() const;
00128 
00130   double operator*(const CV4D&) const;
00131 
00133   CV4D operator*(double) const;
00134 
00136   CV4D operator/(double);
00137 
00142   CV4D operator|(const CV4D&) const;
00143 
00147   double& operator[](int i) { return m_ard[i]; };
00148 
00150   double operator[](int i) const { return m_ard[i]; };
00151 
00153   friend CV4D operator*(double, const CV4D&);
00154 
00155 
00156 
00158   // METHODS //
00160 
00162   double getX() const   { return m_ard[0]; };
00163   
00165   double getY() const   { return m_ard[1]; };
00166   
00168   double getZ() const   { return m_ard[2]; };
00169   
00171   double getW() const   { return m_ard[3]; };
00172 
00174   void setX(double rdX) { m_ard[0] = rdX; };
00175 
00177   void setY(double rdY) { m_ard[1] = rdY; };
00178 
00180   void setZ(double rdZ) { m_ard[2] = rdZ; };
00181 
00183   void setW(double rdW) { m_ard[3] = rdW; };
00184 
00187   void setCoord(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00188                                                                   m_ard[1] = rdY;
00189                                                                   m_ard[2] = rdZ;
00190                                                                   m_ard[3] = rdW; 
00191                                                                   return; };
00192 
00194   double getNorm() const;
00195 
00197   void normalize();
00198 
00200   CV4D getNormalized() const;
00201 
00203   void print() const;
00204   
00206   friend ostream& operator<<(ostream&, const CV4D&); 
00207 
00209   friend istream& operator>>(istream&, CV4D&); 
00210 
00211 
00212 
00213 protected:
00214   double m_ard[4];
00215 
00216 };
00217 
00218 
00219 
00220 // Function   : operator=
00221 // Parameters : const CV4D& v
00222 // Purpose    : assign another vector to this vector
00223 // Comments   : 
00224 inline const CV4D& CV4D::operator=(const CV4D& v) 
00225 /*******************************************************************/
00226 {
00227   m_ard[0] = v.m_ard[0];
00228   m_ard[1] = v.m_ard[1];
00229   m_ard[2] = v.m_ard[2];
00230   m_ard[3] = v.m_ard[3];
00231 
00232   return *this;
00233 }
00234 
00235 #endif // __CV4D_H_

Generated on Wed Mar 5 18:23:25 2003 for QGLViewer by doxygen1.3-rc3