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

C:/temp/src/j2k/Beta/3D/Sommet.cpp

Go to the documentation of this file.
00001 // Classe des sommets 3D en coordonnées homogènes.
00002 
00003 #ifndef __J2K__Sommet_CPP__
00004 #define __J2K__Sommet_CPP__
00005 
00006 #include "sommet.hpp"
00007 #include <math.h>
00008 
00009 ///////////////////////////////////////////////////////////////////////////
00010 // Sommets 2D class
00011 ///////////////////////////////////////////////////////////////////////////
00012 const Sommet2D& Sommet2D::operator=( const Sommet2D& v )
00013 {
00014   x = v.x;
00015   y = v.y;
00016   return *this;
00017 }
00018 
00019 ///////////////////////////////////////////////////////////////////////////
00020 // Sommets 3D class
00021 ///////////////////////////////////////////////////////////////////////////
00022 const Sommet3D& Sommet3D::operator=( const Sommet3D& v )
00023 {
00024   x = v.x;
00025   y = v.y;
00026   z = v.z; 
00027   return *this;
00028 }
00029 
00030 const Sommet3D& Sommet3D::operator=( const Sommet2D& v )
00031 {
00032   x = v.x; 
00033   y = v.y;
00034   return *this;
00035 }
00036 
00037 ///////////////////////////////////////////////////////////////////////////
00038 // Sommets 3D class with homogeneous coordonates
00039 ///////////////////////////////////////////////////////////////////////////
00040 const Sommet3DH& Sommet3DH::operator=( const Sommet3DH& v )
00041 {
00042   x = v.x;
00043   y = v.y;
00044   z = v.z;
00045   w = v.w; 
00046   return *this;
00047 }
00048 
00049 const Sommet3DH& Sommet3DH::operator=( const Sommet3D& v )
00050 {
00051   x = v.x;
00052   y = v.y;
00053   z = v.z;
00054   w = 1;
00055   return *this;
00056 }
00057 
00058 const Sommet3DH& Sommet3DH::operator=( const Sommet2D& v )
00059 {
00060   x = v.x; 
00061   y = v.y; 
00062   z = 0; 
00063   w = 1;
00064   return *this;
00065 }
00066 
00067 const Sommet3DH& Sommet3DH::multiplyByMatrix( const Matrice44& m )
00068 {
00069 
00070  realtype tmp_x = x * m.xx + y * m.yx +
00071                   z * m.zx + w * m.wx;
00072 
00073  realtype tmp_y = x * m.xy + y * m.yy +
00074                   z * m.zy + w * m.wy;
00075  
00076  realtype tmp_z = x * m.xz + y * m.yz +
00077                   z * m.zz + w * m.wz;
00078 
00079  realtype tmp_w = x * m.xw + y * m.yw +
00080                   z * m.zw + w * m.ww;
00081 
00082  x = tmp_x;
00083  y = tmp_y;
00084  z = tmp_z;
00085  w = tmp_w;
00086 
00087  return *this;
00088 }
00089 
00090 ///////////////////////////////////////////////////////////////////////////
00091 // Read from a formated stream
00092 ///////////////////////////////////////////////////////////////////////////
00093 istream& operator>>( istream& in, const Pixel& p )
00094 {
00095  return in >> p.x >> p.y;
00096 }
00097 
00098 ///////////////////////////////////////////////////////////////////////////
00099 // NOTICE:
00100 // *******
00101 //
00102 // Borland C++ 5.0 retro-compatibility
00103 // Since fstream on this compiler cannot read correctly floating-point
00104 // we use a char buffer and atof() to read float numbers.
00105 //
00106 // Since new version should do it correctly, I am planning to write
00107 // a #ifdef version to solve the bug for that compiler
00108 // and a normal version for new compilers.
00109 //
00110 // This notice is good for all the following istream's...
00111 ///////////////////////////////////////////////////////////////////////////
00112 
00113 istream& operator>>( istream& in, const Sommet2D& s )
00114 {
00115  static char buf[20];  // static for optimization
00116 
00117  in >> buf;
00118  s.x = atof(buf);
00119 
00120  in >> buf;
00121  s.y = atof(buf);
00122 
00123  return in;
00124 }
00125 
00126 istream& operator>>( istream& in, const Sommet3D& s )
00127  {
00128  static char buf[20];  // static for optimization
00129 
00130  in >> buf;
00131  s.x = atof(buf);
00132 
00133  in >> buf;
00134  s.y = atof(buf);
00135 
00136  in >> buf;
00137  s.z = atof(buf);
00138 
00139  return in;
00140  }
00141 
00142 istream& operator>>( istream& in, const Sommet3DH& s)
00143  {
00144  static char buf[20];  // static for optimization
00145 
00146  in >> buf;
00147  s.x = atof(buf);
00148 
00149  in >> buf;
00150  s.y = atof(buf);
00151 
00152  in >> buf;
00153  s.z = atof(buf);
00154 
00155  in >> buf;
00156  s.w = atof(buf);
00157 
00158  return in;
00159 }
00160 
00161 /**** END OF NOTICE ****/
00162 
00163 /////////////////////////////////////////////////////////////////////////
00164 // Write to a formated stream       
00165 /////////////////////////////////////////////////////////////////////////
00166 ostream& operator<<( ostream& out, const Pixel&& p )
00167 {
00168   return out << p.x << ' ' << p.y;
00169 }
00170 
00171 ostream& operator<<( ostream& out, const Sommet2D& s )
00172 { 
00173   return out << s.x << ' ' << s.y << '\n';
00174 }
00175 
00176 ostream& operator<<( ostream& out, const Sommet3D& s )
00177 {
00178   return out << s.x << ' ' << s.y << ' ' << s.z << '\n';
00179 }
00180 
00181 ostream& operator<<( ostream& out, const Sommet3DH& s )
00182 {
00183   return out << s.x << ' ' << s.y << ' '
00184              << s.z << ' ' << s.w << '\n';
00185 }
00186 
00187 #endif

Generated on Sun Oct 14 18:46:08 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001