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

CP4D.h

Go to the documentation of this file.
00001 /*
00002  * CP4D.h
00003  * $Id: CP4D.h,v 1.2 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 
00024 #ifndef __CP4D_H
00025 #define __CP4D_H
00026 
00027 
00028 
00029 // System
00031 #include <math.h>
00032 #include <iostream.h>
00033 
00034 // Own
00036 #include "CV4D.h"
00037 
00038 // forward declarations
00040 class CP3D;
00041 
00042 
00047 class CP4D {   
00048 public:
00049   static double epsilon;
00050 
00053   CP4D() { m_ard[0] = 0.0;
00054            m_ard[1] = 0.0;
00055            m_ard[2] = 0.0;
00056            m_ard[3] = 0.0; };
00057 
00060   CP4D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00061                                              m_ard[1] = rdY;
00062                                              m_ard[2] = rdZ;
00063                                              m_ard[3] = 1; };
00064 
00067   CP4D(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX;
00068                                                          m_ard[1] = rdY;
00069                                                          m_ard[2] = rdZ;
00070                                                          m_ard[3] = rdW; };
00071 
00074   CP4D(const CP4D& Point) { m_ard[0] = Point[0];
00075                             m_ard[1] = Point[1];
00076                             m_ard[2] = Point[2];
00077                             m_ard[3] = Point[3]; };
00078 
00079 
00080 
00082   // OVERLOADED OPERATORS //
00084 
00087   operator CP3D() const;
00088 
00090   const CP4D& operator=(const CP4D&);
00091 
00096   int operator==(const CP4D&);
00097 
00101   int operator!=(const CP4D&);
00102 
00104   CP4D& operator+=(const CV4D&);
00105 
00107   CP4D& operator-=(const CV4D&);
00108 
00110   CV4D operator-(const CP4D&) const;
00111 
00113   CP4D operator+(const CV4D&) const;
00114 
00116   CP4D operator-(const CV4D&) const;
00117 
00119   CP4D operator-() const;
00120 
00124   double& operator[](int i) { return m_ard[i]; };
00125 
00127   double operator[](int i) const { return m_ard[i]; };
00128 
00129 
00130 
00132   // METHODS //
00134 
00138   CV4D getCV4D() const;
00139 
00141   double getX() const   { return m_ard[0]; };
00142   
00144   double getY() const   { return m_ard[1]; };
00145   
00147   double getZ() const   { return m_ard[2]; };
00148   
00150   double getW() const   { return m_ard[3]; };
00151 
00153   void setX(double rdX) { m_ard[0] = rdX; };
00154 
00156   void setY(double rdY) { m_ard[1] = rdY; };
00157 
00159   void setZ(double rdZ) { m_ard[2] = rdZ; };
00160 
00162   void setW(double rdW) { m_ard[3] = rdW; };
00163 
00166   void setCoord(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00167                                                                   m_ard[1] = rdY;
00168                                                                   m_ard[2] = rdZ; 
00169                                                                   m_ard[3] = rdW; 
00170                                                                   return; };
00171 
00173   void print() const;
00174   
00175 
00176 
00178   // FRIENDS //
00180  
00182   friend ostream& operator<<(ostream&, const CP4D&); 
00183 
00185   friend istream& operator>>(istream&, CP4D&); 
00186 
00187   /*
00188     CP4D operator*(double& a)
00189     { CP4D pnt;pnt.m_ard[0]=a*m_ard[0]; pnt.m_ard[1]=a*m_ard[1]; pnt.m_ard[2]=a*m_ard[2]; return pnt;}
00190     friend CP4D operator*(double a,CP4D& p1)
00191     { return CP4D(a*p1.m_ard[0], a*p1.m_ard[1], a*p1.m_ard[2]); }
00192     friend CP4D  AffinComb(CP4D&,double,CP4D&);
00193     friend double dist(CP4D&, CP4D&);
00194   */
00195 
00197   friend inline CP4D AffinComb3(double, const CP4D&, 
00198                                 double, const CP4D&,
00199                                 double, const CP4D&);
00200  
00201 
00202 private:
00203   friend class CP3D;
00204 
00205 protected:
00206   double m_ard[4];
00207 };
00208 
00209 
00210 
00211 
00212 
00213 // Function   : operator=
00214 // Parameters : const CP4D& cPoint
00215 // Purpose    : 
00216 // Comments   :
00217 inline const CP4D& CP4D::operator=(const CP4D& cPoint) {
00218 /*******************************************************************/
00219   m_ard[0] = cPoint.m_ard[0];
00220   m_ard[1] = cPoint.m_ard[1];
00221   m_ard[2] = cPoint.m_ard[2];
00222   m_ard[3] = cPoint.m_ard[3];
00223 
00224   return *this;
00225 }
00226 
00227 
00228 
00229 // Function   : getCV4D
00230 // Parameters : 
00231 // Purpose    : 
00232 // Comments   :
00233 inline CV4D CP4D::getCV4D() const
00234 /*******************************************************************/
00235 {
00236   return CV4D(m_ard[0], m_ard[1], m_ard[2], m_ard[3]);
00237 }
00238   
00239 
00240 
00241 // Function   : AffinComb3
00242 // Parameters : double r, const CP4D& R, double s, const CP4D& S,
00243 //              double t, const CP4D &T
00244 // Purpose    : 
00245 // Comments   :
00246 inline CP4D AffinComb3(double r, const CP4D& R, double s, const CP4D& S,
00247                        double t, const CP4D &T)
00248 /*******************************************************************/
00249 {
00250   return CP4D(r*R[0] + s*S[0] + t*T[0],
00251               r*R[1] + s*S[1] + t*T[1],
00252               r*R[2] + s*S[2] + t*T[2],
00253               r*R[3] + s*S[3] + t*T[3]);
00254 }
00255 
00256 #endif

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