00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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