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

CP3D.h

Go to the documentation of this file.
00001 /*
00002  * CP3D.h
00003  * $Id: CP3D.h,v 1.3 2001/09/28 11:06:08 mjanich Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Michael Meissner
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 //  Description : Class CP3D
00024 //  Purpose     : Provides  funcionality
00025 
00026 
00027 #ifndef __CP3D_H
00028 #define __CP3D_H
00029 
00030 
00031 // System
00033 #include <math.h>
00034 #include <iostream.h>
00035 
00036 // Own
00038 #include "CV3D.h"
00039 #include "CP4D.h"
00040 
00041 // forward declarations
00043 class CV3D;
00044 
00045 
00046 
00047 
00052 class CP3D 
00053 {   
00054 public:
00055   static double epsilon;
00056 
00059   CP3D() { m_ard[0] = 0.0;
00060            m_ard[1] = 0.0;
00061            m_ard[2] = 0.0; };
00062 
00065   CP3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00066                                              m_ard[1] = rdY;
00067                                              m_ard[2] = rdZ; }
00068 
00071   CP3D(const CP3D& Point) { m_ard[0] = Point[0];
00072                             m_ard[1] = Point[1];
00073                             m_ard[2] = Point[2]; }
00074 
00075 
00077   // OVERLOADED OPERATORS //
00079  
00082   operator CP4D() const;
00083 
00085   const CP3D& operator=(const CP3D&);
00086 
00091   int operator==(const CP3D&) const;
00092 
00096   int operator!=(const CP3D&) const;
00097 
00099   CP3D& operator+=(const CV3D&);
00100 
00102   CP3D& operator-=(const CV3D&);
00103   
00105   CP3D& operator*=(const CV3D&);
00106 
00108   CP3D& operator*=(double);
00109 
00111   CP3D& operator/=(double);
00112 
00114   CP3D operator+(const CV3D&) const;
00115 
00117   CP3D operator+(const CP3D&) const;  // eigentlich nur fuer affine Punkte
00118   
00120   CP3D operator-(const CV3D&) const;
00121 
00123   CV3D operator-(const CP3D&) const ;
00124 
00126   CP3D operator*(const CV3D&) const;  // scaling
00127 
00129   CP3D operator*(double) const;
00130 
00132   CP3D operator/(const CV3D&) const;
00133 
00135   CP3D operator/(double) const;
00136 
00140   double& operator [] (int i) { return m_ard[i]; };
00141 
00143   double operator[](int i) const { return m_ard[i]; };
00144 
00145 
00147   // METHODS //
00149   
00151   double getMinComponent(void) const    { return m_ard[getMinComponentCoord()]; };
00152  
00154   double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00155  
00157   double getMaxComponent(void) const    { return m_ard[getMaxComponentCoord()]; };
00158  
00160   double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00161  
00163   int getMinComponentCoord(void) const;
00164 
00166   int getAbsMinComponentCoord(void) const;
00167 
00169   int getMaxComponentCoord(void) const;
00170 
00172   int getAbsMaxComponentCoord(void) const;
00173 
00177   CV3D getCV3D() const;
00178 
00180   double getX(void) const  { return m_ard[0]; };
00181 
00183   double getY(void) const  { return m_ard[1]; };
00184 
00186   double getZ(void) const  { return m_ard[2]; };
00187 
00189   void setX(double rdX)    { m_ard[0] = rdX; return; };
00190 
00192   void setY(double rdY)    { m_ard[1] = rdY; return; };
00193 
00195   void setZ(double rdZ)    { m_ard[2] = rdZ; return; };
00196 
00199   void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 
00200                                                       m_ard[1] = rdY;
00201                                                       m_ard[2] = rdZ; 
00202                                                       return; };
00203 
00205   // FRIENDS //
00207   
00209   friend CP3D AffinComb(const CP3D&, double, const CP3D&);
00210 
00212   friend CP3D AffinComb3(double r, const CP3D& R, 
00213                          double s, const CP3D& S,
00214                          double t, const CP3D T) { 
00215                                   return CP3D(r*R[0] + s*S[0] + t*T[0],
00216                                               r*R[1] + s*S[1] + t*T[1],
00217                                               r*R[2] + s*S[2] + t*T[2]); };
00218 
00220   friend double dist(const CP3D&, const CP3D&);
00221 
00223   friend double quaddist(const CP3D&, const CP3D&);
00224 
00226   friend CP3D Min(const CP3D&, const CP3D&);
00227 
00229   friend CP3D Max(const CP3D&, const CP3D&);
00230 
00232   friend CP3D operator*(double, const CP3D&);
00233 
00235   friend CP3D MidPoint(const CP3D&, const CP3D&);
00236 
00237 
00238   // output to stderr
00240   /** Prints a point to the standard output. */
00241   void print() const;
00242 
00244   friend inline ostream& operator<<(ostream&, const CP3D&);
00245 
00247   friend inline istream& operator>>(istream&, CP3D&);
00248 
00249 protected:
00250   double m_ard[3];
00251 };
00252 
00253 
00254 
00255 // Function   : operator=
00256 // Parameters : const CP3D& p1
00257 // Purpose    : assign another point to this point
00258 // Comments   : 
00259 inline const CP3D& CP3D::operator=(const CP3D& p1)
00260 /*******************************************************************/
00261 {
00262   m_ard[0] = p1.m_ard[0];
00263   m_ard[1] = p1.m_ard[1];
00264   m_ard[2] = p1.m_ard[2];
00265   return *this;
00266 }
00267 
00268 
00269 
00270 // Function   : getCV3D
00271 // Parameters : 
00272 // Purpose    : Convert CP3D to CV3D
00273 // Comments   : 
00274 inline CV3D CP3D::getCV3D() const
00275 /*******************************************************************/
00276 {
00277   return CV3D(m_ard[0], m_ard[1], m_ard[2]);
00278 }
00279 
00280 
00281 
00282 // Function   : operator<<
00283 // Parameters : ostream& s, const CP3D& pnt
00284 // Purpose    : 
00285 // Comments   : 
00286 inline ostream& operator<<(ostream& s, const CP3D& pnt)
00287 /*******************************************************************/
00288 {   
00289   return s << "(" << pnt.m_ard[0] << "," << pnt.m_ard[1] << "," << pnt.m_ard[2] << ")"; 
00290 }
00291 
00292 
00293 
00294 // Function   : operator>>
00295 // Parameters : istream& s, CP3D& pnt
00296 // Purpose    : 
00297 // Comments   : 
00298 inline istream& operator>>(istream& s, CP3D& pnt)
00299 /*******************************************************************/
00300 {   
00301   char c;
00302   return s >> c >> pnt.m_ard[0] >> c >> pnt.m_ard[1] >> c >> pnt.m_ard[2] >> c;
00303 }
00304 
00305 #endif

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