Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

Midpoint.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Eric Bohm
00003  *
00004  *This program is free software; you can redistribute it and/or modify
00005  *it under the terms of the GNU General Public License as published by
00006  *the Free Software Foundation version 2 of the License.
00007  * 
00008  *This program is distributed in the hope that it will be useful, but
00009  *WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  *General Public License for more details.
00012  * 
00013  *You should have received a copy of the GNU General Public License along
00014  *with this program; if not, write to the Free Software Foundation, Inc.,
00015  *675 Mass Ave, Cambridge, MA 02139, USA.
00016  *
00017  */
00018 
00019 #ifndef IS_MIDPOINT_DEF_SIG
00020 #define IS_MIDPOINTS_DEF_SIG 1
00021 #include <math.h>
00022 #include <string.h>
00024 
00030 class Midpoint
00031 {
00032 private:
00033   double mx, my, mz;
00034   char length[30];
00035 public:
00037   Midpoint(double imx, double imy, double imz, double ilength)
00038     :mx(imx), my(imy), mz(imz)
00039   {
00040     snprintf(length, 30, "%12.6f", ilength);
00041   }
00043   Midpoint(double x1, double x2, double y1, double y2, double z1, double z2)
00044   {
00045     mx = (x1 + x2) / 2.0;
00046     my = (y1 + y2) / 2.0;
00047     mz = (z1 + z2) / 2.0;
00048     snprintf(length, 30, "%12.6f",
00049              sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2)));
00050   }
00052   bool operator==(const Midpoint & obj) const
00053   {
00054     return ((mx == obj.mx) && (my == obj.my) && (mz == obj.mz));
00055   }
00057   Midpoint & operator=(const Midpoint & obj)
00058   {
00059     mx = obj.mx;
00060     my = obj.my;
00061     mz = obj.mz;
00062     strncpy(length, obj.length, 30);
00063     return *this;
00064   }
00066   GLdouble get_mx()
00067   {
00068     return (mx);
00069   }
00070 
00072   void set_mx(GLdouble ix)
00073   {
00074     mx = ix;
00075   }
00076 
00078   GLdouble get_my()
00079   {
00080     return (my);
00081   }
00082 
00084   void set_my(GLdouble iy)
00085   {
00086     my = iy;
00087   }
00088 
00090   GLdouble get_mz()
00091   {
00092     return (mz);
00093   }
00094 
00096   void set_mz(GLdouble iz)
00097   {
00098     mz = iz;
00099   }
00100 
00102   char *get_length()
00103   {
00104     return length;
00105   }
00106 
00108   void set_length(char *inlength)
00109   {
00110     strncpy(length, inlength, 30);
00111   }
00112 
00113 };
00114 #endif

Generated on Wed Oct 29 10:01:52 2003 for Tetraviewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002