Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CV3D.h

Go to the documentation of this file.
00001 /*
00002  * CV3D.h
00003  * $Id: CV3D.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 __CV3D_H
00033 #define __CV3D_H
00034 
00035 
00036 
00037 // System
00039 #include <math.h>
00040 #ifdef _MSC_VER
00041 #if _MSC_VER >= 1300
00042 #include <iostream>
00043 #endif
00044 #else
00045 #include <iostream.h>
00046 #endif
00047 
00048 
00049 // Own
00051 //#include "CP3D.h"
00052 
00053 using namespace std;
00054 // Forward declaration
00056 class CV4D;
00057 
00058 
00059 
00065 class CV3D {
00066 public:
00067   static double epsilon;
00068 
00071   CV3D(void) { m_ard[0] = 0.0;
00072                m_ard[1] = 0.0;
00073                m_ard[2] = 0.0; };
00074 
00077   CV3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00078                                              m_ard[1] = rdY;
00079                                              m_ard[2] = rdZ; };
00080 
00083   CV3D(const CV3D& Vector) { m_ard[0] = Vector.m_ard[0];
00084                              m_ard[1] = Vector.m_ard[1];
00085                              m_ard[2] = Vector.m_ard[2]; };
00086 
00088   ~CV3D(void) {};
00089 
00090 
00091 
00093   // OVERLOADED OPERATORS //
00095 
00099   operator CV4D() const;
00100 
00102   const CV3D& operator=(const CV3D&);
00103 
00107   bool operator==(const CV3D&) const;
00108 
00112   bool operator!=(const CV3D&) const;
00113 
00115   CV3D& operator+=(const CV3D&);
00116 
00118   CV3D& operator-=(const CV3D&);
00119 
00121   CV3D& operator*=(double);
00122 
00124   CV3D& operator/=(double);
00125 
00127   CV3D operator+(const CV3D&) const;
00128 
00130   CV3D operator-(const CV3D&) const;
00131 
00133   CV3D operator-(void) const;
00134 
00136   double operator*(const CV3D&) const;
00137 
00139   CV3D operator*(double) const;
00140 
00142   CV3D operator/(double) const;
00143 
00145   CV3D operator|(const CV3D&) const;
00146 
00150   double& operator[](int i) { return m_ard[i]; };
00151 
00153   double operator[](int i) const { return m_ard[i]; };
00154 
00156   friend CV3D operator*(double, const CV3D&); 
00157 
00158 
00159 
00161   // METHODS //
00163 
00165   double getMinComponent(void) const    { return m_ard[getMinComponentCoord()]; };
00166  
00168   double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00169  
00171   double getMaxComponent(void) const    { return m_ard[getMaxComponentCoord()]; };
00172  
00174   double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00175  
00177   int getMinComponentCoord(void) const;
00178 
00180   int getAbsMinComponentCoord(void) const;
00181 
00183   int getMaxComponentCoord(void) const;
00184 
00186   int getAbsMaxComponentCoord(void) const;
00187 
00189   double getX(void) const { return m_ard[0]; };
00190   
00192   double getY(void) const { return m_ard[1]; };
00193   
00195   double getZ(void) const { return m_ard[2]; };
00196 
00198   void setX(double rdX)   { m_ard[0] = rdX; };
00199 
00201   void setY(double rdY)   { m_ard[1] = rdY; };
00202 
00204   void setZ(double rdZ)   { m_ard[2] = rdZ; };
00205 
00208   void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 
00209                                                       m_ard[1] = rdY; 
00210                                                       m_ard[2] = rdZ; 
00211                                                       return; };
00212 
00214   double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1] + m_ard[2]*m_ard[2]); };
00215 
00217   void normalize(void);
00218 
00220   CV3D getNormalized(void) const;
00221 
00223   void print(void) const;
00224   
00226   friend ostream& operator<<(ostream&, const CV3D&); 
00227 
00229   friend istream& operator>>(istream&, CV3D&); 
00230 
00231 
00232 protected:
00233   double m_ard[3];
00234 
00235 };
00236 
00237 
00238 
00239 // Function   : operator=
00240 // Parameters : const CP3D& p1
00241 // Purpose    : assign another point to this point
00242 // Comments   : 
00243 inline const CV3D& CV3D::operator=(const CV3D& v)
00244 /*******************************************************************/
00245 {
00246   m_ard[0] = v[0];
00247   m_ard[1] = v[1];
00248   m_ard[2] = v[2];
00249   return *this;
00250 }
00251 
00252 #endif // _CV3D_H_

Generated on Wed Nov 17 23:15:19 2004 for QGLViewer by  doxygen 1.3.9.1