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

CP4D.h

Go to the documentation of this file.
00001 /*
00002  * CP4D.h
00003  * $Id: CP4D.h,v 1.3 2001/11/15 16:54:52 guenth 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  * 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 #ifndef __CP4D_H
00032 #define __CP4D_H
00033 
00034 
00035 
00036 // System
00038 #include <math.h>
00039 #include <iostream.h>
00040 
00041 // Own
00043 #include "CV4D.h"
00044 
00045 // forward declarations
00047 class CP3D;
00048 
00049 
00054 class CP4D {   
00055 public:
00056   static double epsilon;
00057 
00060   CP4D() { m_ard[0] = 0.0;
00061            m_ard[1] = 0.0;
00062            m_ard[2] = 0.0;
00063            m_ard[3] = 0.0; };
00064 
00067   CP4D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX;
00068                                              m_ard[1] = rdY;
00069                                              m_ard[2] = rdZ;
00070                                              m_ard[3] = 1; };
00071 
00074   CP4D(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX;
00075                                                          m_ard[1] = rdY;
00076                                                          m_ard[2] = rdZ;
00077                                                          m_ard[3] = rdW; };
00078 
00081   CP4D(const CP4D& Point) { m_ard[0] = Point[0];
00082                             m_ard[1] = Point[1];
00083                             m_ard[2] = Point[2];
00084                             m_ard[3] = Point[3]; };
00085 
00086 
00087 
00089   // OVERLOADED OPERATORS //
00091 
00094   operator CP3D() const;
00095 
00097   const CP4D& operator=(const CP4D&);
00098 
00103   int operator==(const CP4D&);
00104 
00108   int operator!=(const CP4D&);
00109 
00111   CP4D& operator+=(const CV4D&);
00112 
00114   CP4D& operator-=(const CV4D&);
00115 
00117   CV4D operator-(const CP4D&) const;
00118 
00120   CP4D operator+(const CV4D&) const;
00121 
00123   CP4D operator-(const CV4D&) const;
00124 
00126   CP4D operator-() const;
00127 
00131   double& operator[](int i) { return m_ard[i]; };
00132 
00134   double operator[](int i) const { return m_ard[i]; };
00135 
00136 
00137 
00139   // METHODS //
00141 
00145   CV4D getCV4D() const;
00146 
00148   double getX() const   { return m_ard[0]; };
00149   
00151   double getY() const   { return m_ard[1]; };
00152   
00154   double getZ() const   { return m_ard[2]; };
00155   
00157   double getW() const   { return m_ard[3]; };
00158 
00160   void setX(double rdX) { m_ard[0] = rdX; };
00161 
00163   void setY(double rdY) { m_ard[1] = rdY; };
00164 
00166   void setZ(double rdZ) { m_ard[2] = rdZ; };
00167 
00169   void setW(double rdW) { m_ard[3] = rdW; };
00170 
00173   void setCoord(double rdX, double rdY, double rdZ, double rdW) { m_ard[0] = rdX; 
00174                                                                   m_ard[1] = rdY;
00175                                                                   m_ard[2] = rdZ; 
00176                                                                   m_ard[3] = rdW; 
00177                                                                   return; };
00178 
00180   void print() const;
00181   
00182 
00183 
00185   // FRIENDS //
00187  
00189   friend ostream& operator<<(ostream&, const CP4D&); 
00190 
00192   friend istream& operator>>(istream&, CP4D&); 
00193 
00194   /*
00195     CP4D operator*(double& a)
00196     { 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;}
00197     friend CP4D operator*(double a,CP4D& p1)
00198     { return CP4D(a*p1.m_ard[0], a*p1.m_ard[1], a*p1.m_ard[2]); }
00199     friend CP4D  AffinComb(CP4D&,double,CP4D&);
00200     friend double dist(CP4D&, CP4D&);
00201   */
00202 
00204   friend inline CP4D AffinComb3(double, const CP4D&, 
00205                                 double, const CP4D&,
00206                                 double, const CP4D&);
00207  
00208 
00209 private:
00210   friend class CP3D;
00211 
00212 protected:
00213   double m_ard[4];
00214 };
00215 
00216 
00217 
00218 
00219 
00220 // Function   : operator=
00221 // Parameters : const CP4D& cPoint
00222 // Purpose    : 
00223 // Comments   :
00224 inline const CP4D& CP4D::operator=(const CP4D& cPoint) {
00225 /*******************************************************************/
00226   m_ard[0] = cPoint.m_ard[0];
00227   m_ard[1] = cPoint.m_ard[1];
00228   m_ard[2] = cPoint.m_ard[2];
00229   m_ard[3] = cPoint.m_ard[3];
00230 
00231   return *this;
00232 }
00233 
00234 
00235 
00236 // Function   : getCV4D
00237 // Parameters : 
00238 // Purpose    : 
00239 // Comments   :
00240 inline CV4D CP4D::getCV4D() const
00241 /*******************************************************************/
00242 {
00243   return CV4D(m_ard[0], m_ard[1], m_ard[2], m_ard[3]);
00244 }
00245   
00246 
00247 
00248 // Function   : AffinComb3
00249 // Parameters : double r, const CP4D& R, double s, const CP4D& S,
00250 //              double t, const CP4D &T
00251 // Purpose    : 
00252 // Comments   :
00253 inline CP4D AffinComb3(double r, const CP4D& R, double s, const CP4D& S,
00254                        double t, const CP4D &T)
00255 /*******************************************************************/
00256 {
00257   return CP4D(r*R[0] + s*S[0] + t*T[0],
00258               r*R[1] + s*S[1] + t*T[1],
00259               r*R[2] + s*S[2] + t*T[2],
00260               r*R[3] + s*S[3] + t*T[3]);
00261 }
00262 
00263 #endif

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