00001 /* 00002 * CV3D.h 00003 * $Id: CV3D.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 __CV3D_H 00026 #define __CV3D_H 00027 00028 00029 00030 // System 00032 #include <math.h> 00033 #include <iostream.h> 00034 00035 00036 // Own 00038 //#include "CP3D.h" 00039 00040 // Forward declaration 00042 class CV4D; 00043 00044 00045 00051 class CV3D { 00052 public: 00053 static double epsilon; 00054 00057 CV3D(void) { m_ard[0] = 0.0; 00058 m_ard[1] = 0.0; 00059 m_ard[2] = 0.0; }; 00060 00063 CV3D(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 00064 m_ard[1] = rdY; 00065 m_ard[2] = rdZ; }; 00066 00069 CV3D(const CV3D& Vector) { m_ard[0] = Vector.m_ard[0]; 00070 m_ard[1] = Vector.m_ard[1]; 00071 m_ard[2] = Vector.m_ard[2]; }; 00072 00074 ~CV3D(void) {}; 00075 00076 00077 00079 // OVERLOADED OPERATORS // 00081 00085 operator CV4D() const; 00086 00088 const CV3D& operator=(const CV3D&); 00089 00093 bool operator==(const CV3D&) const; 00094 00098 bool operator!=(const CV3D&) const; 00099 00101 CV3D& operator+=(const CV3D&); 00102 00104 CV3D& operator-=(const CV3D&); 00105 00107 CV3D& operator*=(double); 00108 00110 CV3D& operator/=(double); 00111 00113 CV3D operator+(const CV3D&) const; 00114 00116 CV3D operator-(const CV3D&) const; 00117 00119 CV3D operator-(void) const; 00120 00122 double operator*(const CV3D&) const; 00123 00125 CV3D operator*(double) const; 00126 00128 CV3D operator/(double) const; 00129 00131 CV3D operator|(const CV3D&) const; 00132 00136 double& operator[](int i) { return m_ard[i]; }; 00137 00139 double operator[](int i) const { return m_ard[i]; }; 00140 00142 friend CV3D operator*(double, const CV3D&); 00143 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 00175 double getX(void) const { return m_ard[0]; }; 00176 00178 double getY(void) const { return m_ard[1]; }; 00179 00181 double getZ(void) const { return m_ard[2]; }; 00182 00184 void setX(double rdX) { m_ard[0] = rdX; }; 00185 00187 void setY(double rdY) { m_ard[1] = rdY; }; 00188 00190 void setZ(double rdZ) { m_ard[2] = rdZ; }; 00191 00194 void setCoord(double rdX, double rdY, double rdZ) { m_ard[0] = rdX; 00195 m_ard[1] = rdY; 00196 m_ard[2] = rdZ; 00197 return; }; 00198 00200 double getNorm(void) const { return sqrt(m_ard[0]*m_ard[0] + m_ard[1]*m_ard[1] + m_ard[2]*m_ard[2]); }; 00201 00203 void normalize(void); 00204 00206 CV3D getNormalized(void) const; 00207 00209 void print(void) const; 00210 00212 friend ostream& operator<<(ostream&, const CV3D&); 00213 00215 friend istream& operator>>(istream&, CV3D&); 00216 00217 00218 protected: 00219 double m_ard[3]; 00220 00221 }; 00222 00223 00224 00225 // Function : operator= 00226 // Parameters : const CP3D& p1 00227 // Purpose : assign another point to this point 00228 // Comments : 00229 inline const CV3D& CV3D::operator=(const CV3D& v) 00230 /*******************************************************************/ 00231 { 00232 m_ard[0] = v[0]; 00233 m_ard[1] = v[1]; 00234 m_ard[2] = v[2]; 00235 return *this; 00236 } 00237 00238 #endif // _CV3D_H_