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

CV2D.h

Go to the documentation of this file.
00001 /*
00002  * CV2D.h
00003  * $Id: CV2D.h,v 1.2 2001/09/28 11:06:08 mjanich 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  */
00022 
00023 
00024 
00025 #ifndef __CV2D_H
00026 #define __CV2D_H
00027 
00028 
00029 
00030 // System
00032 #include <math.h>
00033 #include <iostream.h>
00034 
00035 
00036 // Own
00038 //#include "CP2D.h"
00039 
00040 // Forward declaration
00042 class CV3D;
00043 
00044 
00045 
00051 class CV2D {
00052 public:
00053   static double epsilon;
00054 
00057   CV2D(void) { m_ard[0] = 0.0;
00058                m_ard[1] = 0.0; };
00059 
00062   CV2D(double rdX, double rdY) { m_ard[0] = rdX;
00063                                  m_ard[1] = rdY; };
00064 
00067   CV2D(const CV2D& Vector) { m_ard[0] = Vector.m_ard[0];
00068                              m_ard[1] = Vector.m_ard[1]; };
00069 
00071   ~CV2D(void) {};
00072 
00073 
00074 
00076   // OVERLOADED OPERATORS //
00078 
00082   operator CV3D() const;
00083 
00085   const CV2D& operator=(const CV2D&);
00086 
00090   bool operator==(const CV2D&) const;
00091 
00095   bool operator!=(const CV2D&) const;
00096 
00098   CV2D& operator+=(const CV2D&);
00099 
00101   CV2D& operator-=(const CV2D&);
00102 
00104   CV2D& operator*=(double);
00105 
00107   CV2D& operator/=(double);
00108 
00110   CV2D operator+(const CV2D&) const;
00111 
00113   CV2D operator-(const CV2D&) const;
00114 
00116   CV2D operator-(void) const;
00117 
00119   double operator*(const CV2D&) const;
00120 
00122   CV2D operator*(double) const;
00123 
00125   CV2D operator/(double) const;
00126 
00130   double& operator[](int i) { return m_ard[i]; };
00131 
00133   double operator[](int i) const { return m_ard[i]; };
00134 
00136   friend CV2D operator*(double, const CV2D&); 
00137 
00138 
00139 
00141   // METHODS //
00143 
00145   double getMinComponent(void) const    { return m_ard[getMinComponentCoord()]; };
00146  
00148   double getAbsMinComponent(void) const { return m_ard[getAbsMinComponentCoord()]; };
00149  
00151   double getMaxComponent(void) const    { return m_ard[getMaxComponentCoord()]; };
00152  
00154   double getAbsMaxComponent(void) const { return m_ard[getAbsMaxComponentCoord()]; };
00155  
00157   int getMinComponentCoord(void) const;
00158 
00160   int getAbsMinComponentCoord(void) const;
00161 
00163   int getMaxComponentCoord(void) const;
00164 
00166   int getAbsMaxComponentCoord(void) const;
00167 
00169   double getX(void) const { return m_ard[0]; };
00170   
00172   double getY(void) const { return m_ard[1]; };
00173   
00175   void setX(double rdX)   { m_ard[0] = rdX; };
00176 
00178   void setY(double rdY)   { m_ard[1] = rdY; };
00179 
00182   void setCoord(double rdX, double rdY) { m_ard[0] = rdX; 
00183                                           m_ard[1] = rdY; 
00184                                           return; };
00185 
00187   double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1]); };
00188 
00190   void normalize(void);
00191 
00193   CV2D getNormalized(void) const;
00194 
00196   void print(void) const;
00197   
00199   friend ostream& operator<<(ostream&, const CV2D&); 
00200 
00202   friend istream& operator>>(istream&, CV2D&); 
00203 
00204 
00205 protected:
00206   double m_ard[2];
00207 
00208 };
00209 
00210 
00211 
00212 // Function   : operator=
00213 // Parameters : const CP2D& p1
00214 // Purpose    : assign another point to this point
00215 // Comments   : 
00216 inline const CV2D& CV2D::operator=(const CV2D& v)
00217 /*******************************************************************/
00218 {
00219   m_ard[0] = v[0];
00220   m_ard[1] = v[1];
00221   return *this;
00222 }
00223 
00224 #endif // _CV2D_H_

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