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

CV3D.h

Go to the documentation of this file.
00001 /*
00002  * CV3D.h
00003  * $Id: CV3D.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 __CV3D_H
00033 #define __CV3D_H
00034 
00035 
00036 
00037 // System
00039 #include <math.h>
00040 #include <iostream.h>
00041 
00042 
00043 // Own
00045 //#include "CP3D.h"
00046 
00047 // Forward declaration
00049 class CV4D;
00050 
00051 
00052 
00058 class CV3D {
00059 public:
00060   static double epsilon;
00061 
00064   CV3D(void) { m_ard[0] = 0.0;
00065                m_ard[1] = 0.0;
00066                m_ard[2] = 0.0; };
00067 
00070   CV3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00071                                              m_ard[1] = rdY;
00072                                              m_ard[2] = rdZ; };
00073 
00076   CV3D(const CV3D& Vector) { m_ard[0] = Vector.m_ard[0];
00077                              m_ard[1] = Vector.m_ard[1];
00078                              m_ard[2] = Vector.m_ard[2]; };
00079 
00081   ~CV3D(void) {};
00082 
00083 
00084 
00086   // OVERLOADED OPERATORS //
00088 
00092   operator CV4D() const;
00093 
00095   const CV3D& operator=(const CV3D&);
00096 
00100   bool operator==(const CV3D&) const;
00101 
00105   bool operator!=(const CV3D&) const;
00106 
00108   CV3D& operator+=(const CV3D&);
00109 
00111   CV3D& operator-=(const CV3D&);
00112 
00114   CV3D& operator*=(double);
00115 
00117   CV3D& operator/=(double);
00118 
00120   CV3D operator+(const CV3D&) const;
00121 
00123   CV3D operator-(const CV3D&) const;
00124 
00126   CV3D operator-(void) const;
00127 
00129   double operator*(const CV3D&) const;
00130 
00132   CV3D operator*(double) const;
00133 
00135   CV3D operator/(double) const;
00136 
00138   CV3D operator|(const CV3D&) const;
00139 
00143   double& operator[](int i) { return m_ard[i]; };
00144 
00146   double operator[](int i) const { return m_ard[i]; };
00147 
00149   friend CV3D operator*(double, const CV3D&); 
00150 
00151 
00152 
00154   // METHODS //
00156 
00158   double getMinComponent(void) const    { return m_ard[getMinComponentCoord()]; };
00159  
00161   double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00162  
00164   double getMaxComponent(void) const    { return m_ard[getMaxComponentCoord()]; };
00165  
00167   double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00168  
00170   int getMinComponentCoord(void) const;
00171 
00173   int getAbsMinComponentCoord(void) const;
00174 
00176   int getMaxComponentCoord(void) const;
00177 
00179   int getAbsMaxComponentCoord(void) const;
00180 
00182   double getX(void) const { return m_ard[0]; };
00183   
00185   double getY(void) const { return m_ard[1]; };
00186   
00188   double getZ(void) const { return m_ard[2]; };
00189 
00191   void setX(double rdX)   { m_ard[0] = rdX; };
00192 
00194   void setY(double rdY)   { m_ard[1] = rdY; };
00195 
00197   void setZ(double rdZ)   { m_ard[2] = rdZ; };
00198 
00201   void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 
00202                                                       m_ard[1] = rdY; 
00203                                                       m_ard[2] = rdZ; 
00204                                                       return; };
00205 
00207   double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1] + m_ard[2]*m_ard[2]); };
00208 
00210   void normalize(void);
00211 
00213   CV3D getNormalized(void) const;
00214 
00216   void print(void) const;
00217   
00219   friend ostream& operator<<(ostream&, const CV3D&); 
00220 
00222   friend istream& operator>>(istream&, CV3D&); 
00223 
00224 
00225 protected:
00226   double m_ard[3];
00227 
00228 };
00229 
00230 
00231 
00232 // Function   : operator=
00233 // Parameters : const CP3D& p1
00234 // Purpose    : assign another point to this point
00235 // Comments   : 
00236 inline const CV3D& CV3D::operator=(const CV3D& v)
00237 /*******************************************************************/
00238 {
00239   m_ard[0] = v[0];
00240   m_ard[1] = v[1];
00241   m_ard[2] = v[2];
00242   return *this;
00243 }
00244 
00245 #endif // _CV3D_H_

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