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

CV4D.h

Go to the documentation of this file.
00001 /*
00002  * CV4D.h
00003  * $Id: CV4D.h,v 1.2 2001/09/28 11:06:08 mjanich 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  */
00022 
00023 
00024 
00025 #ifndef __CV4D_H_
00026 #define __CV4D_H_
00027 
00028 
00029 // System
00031 #include <math.h>
00032 #include <iostream.h>
00033 
00034 
00035 // Own
00037 
00038 
00039 // Forward declarations
00041 class CV3D;
00042 
00043 
00044 
00050 class CV4D {
00051 public:
00052   static double epsilon;
00053 
00057   CV4D() { m_ard[0] = 0.0;
00058            m_ard[1] = 0.0;
00059            m_ard[2] = 0.0;
00060            m_ard[3] = 0.0; };
00061 
00062 
00065   CV4D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 
00066                                              m_ard[1] = rdY; 
00067                                              m_ard[2] = rdZ;
00068                                              m_ard[3] = 1.0; };
00069 
00072   CV4D(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00073                                                          m_ard[1] = rdY; 
00074                                                          m_ard[2] = rdZ;
00075                                                          m_ard[3] = rdW; };
00076 
00079   CV4D(const CV4D& Vector) { m_ard[0] = Vector.m_ard[0];
00080                              m_ard[1] = Vector.m_ard[1];
00081                              m_ard[2] = Vector.m_ard[2];
00082                              m_ard[3] = Vector.m_ard[3]; };
00083 
00084 
00085 
00087   // OVERLOADED OPERATORS //
00089 
00092   operator CV3D() const;
00093 
00095   const CV4D& operator=(const CV4D&);
00096 
00100   bool operator==(const CV4D&) const;
00101 
00105   bool operator!=(const CV4D&) const;
00106 
00108   CV4D& operator+=(const CV4D&);
00109 
00111   CV4D& operator-=(const CV4D&);
00112 
00114   CV4D operator+(const CV4D&) const;
00115 
00117   CV4D operator-(const CV4D&) const;
00118 
00120   CV4D operator-() const;
00121 
00123   double operator*(const CV4D&) const;
00124 
00126   CV4D operator*(double) const;
00127 
00129   CV4D operator/(double);
00130 
00135   CV4D operator|(const CV4D&) const;
00136 
00140   double& operator[](int i) { return m_ard[i]; };
00141 
00143   double operator[](int i) const { return m_ard[i]; };
00144 
00146   friend CV4D operator*(double, const CV4D&);
00147 
00148 
00149 
00151   // METHODS //
00153 
00155   double getX() const   { return m_ard[0]; };
00156   
00158   double getY() const   { return m_ard[1]; };
00159   
00161   double getZ() const   { return m_ard[2]; };
00162   
00164   double getW() const   { return m_ard[3]; };
00165 
00167   void setX(double rdX) { m_ard[0] = rdX; };
00168 
00170   void setY(double rdY) { m_ard[1] = rdY; };
00171 
00173   void setZ(double rdZ) { m_ard[2] = rdZ; };
00174 
00176   void setW(double rdW) { m_ard[3] = rdW; };
00177 
00180   void setCoord(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00181                                                                   m_ard[1] = rdY;
00182                                                                   m_ard[2] = rdZ;
00183                                                                   m_ard[3] = rdW; 
00184                                                                   return; };
00185 
00187   double getNorm() const;
00188 
00190   void normalize();
00191 
00193   CV4D getNormalized() const;
00194 
00196   void print() const;
00197   
00199   friend ostream& operator<<(ostream&, const CV4D&); 
00200 
00202   friend istream& operator>>(istream&, CV4D&); 
00203 
00204 
00205 
00206 protected:
00207   double m_ard[4];
00208 
00209 };
00210 
00211 
00212 
00213 // Function   : operator=
00214 // Parameters : const CV4D& v
00215 // Purpose    : assign another vector to this vector
00216 // Comments   : 
00217 inline const CV4D& CV4D::operator=(const CV4D& v) 
00218 /*******************************************************************/
00219 {
00220   m_ard[0] = v.m_ard[0];
00221   m_ard[1] = v.m_ard[1];
00222   m_ard[2] = v.m_ard[2];
00223   m_ard[3] = v.m_ard[3];
00224 
00225   return *this;
00226 }
00227 
00228 #endif // __CV4D_H_

Generated at Thu Oct 4 17:17:25 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001