00001
00002
00003 #ifndef __J2K__Sommet_CPP__
00004 #define __J2K__Sommet_CPP__
00005
00006 #include "sommet.hpp"
00007 #include <math.h>
00008
00009
00010
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
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
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
00092
00093 istream& operator>>( istream& in, const Pixel& p )
00094 {
00095 return in >> p.x >> p.y;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 istream& operator>>( istream& in, const Sommet2D& s )
00114 {
00115 static char buf[20];
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];
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];
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
00162
00163
00164
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