Go to Overview over all GrAL packages.
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Geometry/coords_3_special.h

Go to the documentation of this file.
00001 #ifndef NMWR_GB_COORDS_3_SPECIALIZATION_H
00002 #define NMWR_GB_COORDS_3_SPECIALIZATION_H
00003 
00004 
00005 // $LICENSE
00006 
00007 
00008 //----------------------------------------------------------------
00009 // 
00010 // to be included by coord.h
00011 // specialization of coordN<N> for N = 3
00012 //
00013 //----------------------------------------------------------------
00014 
00015 template<unsigned N> class coordN;
00016 
00017 class coordN<3> {
00018 public:
00019   typedef double   component;
00020   typedef unsigned index;
00021   typedef coordN<3> self;
00022 
00023   coordN() {}
00024   coordN(const component& x) { X[0] = X[1] = X[2] = x;}
00025   coordN(const component x1, const component x2, const component x3) 
00026   { X[0] = x1; X[1] = x2; X[2] = x3;}
00027   coordN(const self& rhs)    { X[0] = rhs.X[0]; X[1] = rhs.X[1];X[2] = rhs.X[2];}
00028   self& operator=(const self& rhs)
00029   { 
00030     //if(this != & rhs){
00031     X[0] = rhs.X[0]; X[1] = rhs.X[1];X[2] = rhs.X[2];
00032     //}   
00033     return *this;
00034   }
00035 
00036   ~coordN() {}
00037   
00038   component  operator[](index i) const {  _c(i); return X[--i];}
00039   component& operator[](index i)       {  _c(i); return X[--i];}
00040   component  operator()(index i) const {  _c(i); return X[--i];}
00041   component& operator()(index i)       {  _c(i); return X[--i];}
00042 
00043   void _c(index i) const { REQUIRE ( (1 <= i && i <= 3), "i = " << i << '\n',1);}
00044 
00045 
00046   self& operator+=(const self& rhs) { X[0] += rhs.X[0];X[1] += rhs.X[1];X[2] += rhs.X[2]; return *this; }
00047   self& operator-=(const self& rhs) { X[0] -= rhs.X[0];X[1] -= rhs.X[1];X[2] -= rhs.X[2];return *this; }
00048   self& operator*=(const component& rhs) { X[0] *= rhs;X[1] *= rhs;X[2] *= rhs; return *this; }
00049   self& operator/=(const component& rhs) { X[0] /= rhs;X[1] /= rhs;X[2] /= rhs; return *this; }
00050   
00051   friend inline self operator+(const self& ls, const self& rs)
00052   {  return self(ls.X[0]+rs.X[0], ls.X[1]+rs.X[1],ls.X[2]+rs.X[2]);}
00053   friend inline self operator-(const self& ls, const self& rs)
00054   {  return self(ls.X[0]-rs.X[0], ls.X[1]-rs.X[1],ls.X[2]-rs.X[2]);}
00055 
00056   static self origin() { return self(component(0));}
00057   static self Origin() { return self(component(0));}
00058   static index dim()   { return 3;}
00059 private:
00060   component X[3];
00061 };
00062 
00063 template<class T> struct is_specialized;
00064 
00065 template<>
00066 struct is_specialized<coordN<3> > {
00067   static bool specialized() { return true;}
00068   static const char* name() { return "coordN<3>";}
00069 };
00070 
00071 
00072 #endif

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:26 2002 for Geometry by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000