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

CV2D.h

Go to the documentation of this file.
00001 /*
00002  * CV2D.h
00003  * $Id: CV2D.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 __CV2D_H
00033 #define __CV2D_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 "CP2D.h"
00052 
00053 // Forward declaration
00055 class CV3D;
00056 
00057 using namespace std;
00058 
00064 class CV2D {
00065 public:
00066   static double epsilon;
00067 
00070   CV2D(void) { m_ard[0] = 0.0;
00071                m_ard[1] = 0.0; };
00072 
00075   CV2D(double rdX, double rdY) { m_ard[0] = rdX;
00076                                  m_ard[1] = rdY; };
00077 
00080   CV2D(const CV2D& Vector) { m_ard[0] = Vector.m_ard[0];
00081                              m_ard[1] = Vector.m_ard[1]; };
00082 
00084   ~CV2D(void) {};
00085 
00086 
00087 
00089   // OVERLOADED OPERATORS //
00091 
00095   operator CV3D() const;
00096 
00098   const CV2D& operator=(const CV2D&);
00099 
00103   bool operator==(const CV2D&) const;
00104 
00108   bool operator!=(const CV2D&) const;
00109 
00111   CV2D& operator+=(const CV2D&);
00112 
00114   CV2D& operator-=(const CV2D&);
00115 
00117   CV2D& operator*=(double);
00118 
00120   CV2D& operator/=(double);
00121 
00123   CV2D operator+(const CV2D&) const;
00124 
00126   CV2D operator-(const CV2D&) const;
00127 
00129   CV2D operator-(void) const;
00130 
00132   double operator*(const CV2D&) const;
00133 
00135   CV2D operator*(double) const;
00136 
00138   CV2D operator/(double) 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 CV2D operator*(double, const CV2D&); 
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   void setX(double rdX)   { m_ard[0] = rdX; };
00189 
00191   void setY(double rdY)   { m_ard[1] = rdY; };
00192 
00195   void setCoord(double rdX, double rdY) { m_ard[0] = rdX; 
00196                                           m_ard[1] = rdY; 
00197                                           return; };
00198 
00200   double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1]); };
00201 
00203   void normalize(void);
00204 
00206   CV2D getNormalized(void) const;
00207 
00209   void print(void) const;
00210   
00212   friend ostream& operator<<(ostream&, const CV2D&); 
00213 
00215   friend istream& operator>>(istream&, CV2D&); 
00216 
00217 
00218 protected:
00219   double m_ard[2];
00220 
00221 };
00222 
00223 
00224 
00225 // Function   : operator=
00226 // Parameters : const CP2D& p1
00227 // Purpose    : assign another point to this point
00228 // Comments   : 
00229 inline const CV2D& CV2D::operator=(const CV2D& v)
00230 /*******************************************************************/
00231 {
00232   m_ard[0] = v[0];
00233   m_ard[1] = v[1];
00234   return *this;
00235 }
00236 
00237 #endif // _CV2D_H_

Generated on Wed Sep 14 04:50:33 2005 for QGLViewer by  doxygen 1.4.4