00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 char map_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map.C,v 1.9 2008/09/29 13:23:51 j_novak Exp $" ;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 #include <math.h>
00119
00120
00121 #include "map.h"
00122 #include "cmp.h"
00123 #include "metric.h"
00124 #include "utilitaires.h"
00125
00126
00127
00128
00129
00130
00131
00132 Map::Map(const Mg3d& mgi) : mg(&mgi),
00133 ori_x(0), ori_y(0), ori_z(0), rot_phi(0),
00134 bvect_spher(ori_x, ori_y, ori_z, rot_phi,
00135 "Mapping orthonormal spherical basis"),
00136 bvect_cart(rot_phi, "Mapping Cartesian basis"),
00137 p_flat_met_spher(0x0),
00138 p_flat_met_cart(0x0),
00139 p_mp_angu(0x0)
00140 {
00141
00142
00143
00144 p_cmp_zero = new Cmp(this) ;
00145 p_cmp_zero->set_etat_zero() ;
00146 }
00147
00148
00149
00150 Map::Map(const Map& mp) : mg(mp.mg),
00151 ori_x(mp.ori_x), ori_y(mp.ori_y), ori_z(mp.ori_z),
00152 rot_phi(mp.rot_phi),
00153 bvect_spher(ori_x, ori_y, ori_z, rot_phi,
00154 "Mapping orthonormal spherical basis"),
00155 bvect_cart(rot_phi, "Mapping Cartesian basis"),
00156 p_flat_met_spher(0x0),
00157 p_flat_met_cart(0x0),
00158 p_mp_angu(0x0)
00159 {
00160
00161
00162
00163 p_cmp_zero = new Cmp(this) ;
00164 p_cmp_zero->set_etat_zero() ;
00165 }
00166
00167
00168
00169 Map::Map(const Mg3d& mgi, FILE* fd) : mg(&mgi),
00170 bvect_spher(0., 0., 0., 0.,
00171 "Mapping orthonormal spherical basis"),
00172 bvect_cart(0., "Mapping Cartesian basis"),
00173 p_flat_met_spher(0x0),
00174 p_flat_met_cart(0x0),
00175 p_mp_angu(0x0)
00176 {
00177 Mg3d* mg_tmp = new Mg3d(fd) ;
00178 if (*mg != *mg_tmp) {
00179 cout << "Map::Map(const Mg3d&, FILE*): grid not consistent !"
00180 << endl ;
00181 abort() ;
00182 }
00183 delete mg_tmp ;
00184
00185 fread_be(&ori_x, sizeof(double), 1, fd) ;
00186 fread_be(&ori_y, sizeof(double), 1, fd) ;
00187 fread_be(&ori_z, sizeof(double), 1, fd) ;
00188 fread_be(&rot_phi, sizeof(double), 1, fd) ;
00189
00190 bvect_spher.set_ori(ori_x, ori_y, ori_z) ;
00191 bvect_spher.set_rot_phi(rot_phi) ;
00192 bvect_cart.set_rot_phi(rot_phi) ;
00193
00194
00195
00196
00197 p_cmp_zero = new Cmp(this) ;
00198 p_cmp_zero->set_etat_zero() ;
00199 }
00200
00201
00202
00203
00204
00205
00206 Map::~Map() {
00207 if (p_flat_met_spher != 0x0) delete p_flat_met_spher ;
00208 if (p_flat_met_cart != 0x0) delete p_flat_met_cart ;
00209 if (p_mp_angu != 0x0) delete p_mp_angu ;
00210 delete p_cmp_zero ;
00211 }
00212
00213
00214
00215
00216
00217 void Map::sauve(FILE* fd) const {
00218
00219 mg->sauve(fd) ;
00220
00221 fwrite_be(&ori_x, sizeof(double), 1, fd) ;
00222 fwrite_be(&ori_y, sizeof(double), 1, fd) ;
00223 fwrite_be(&ori_z, sizeof(double), 1, fd) ;
00224 fwrite_be(&rot_phi, sizeof(double), 1, fd) ;
00225 }
00226
00227
00228
00229
00230
00231
00232 ostream& operator<<(ostream& o, const Map & cv) {
00233 o << "Absolute coordinates of the mapping origin: " << endl ;
00234 o << " X_0, Y_0, Z_0 : " << cv.get_ori_x() << " "
00235 << cv.get_ori_y() << " " << cv.get_ori_z() << endl ;
00236 o << "Rotation angle between the x-axis and X-axis : "
00237 << cv.get_rot_phi() << endl ;
00238 cv >> o ;
00239 return o ;
00240 }
00241
00242
00243
00244
00245
00246 void Map::set_ori(double xo, double yo, double zo) {
00247 ori_x = xo ;
00248 ori_y = yo ;
00249 ori_z = zo ;
00250
00251 bvect_spher.set_ori(ori_x, ori_y, ori_z) ;
00252
00253 reset_coord() ;
00254 }
00255
00256 void Map::set_rot_phi(double newphi) {
00257
00258 rot_phi = newphi ;
00259
00260 bvect_spher.set_rot_phi(rot_phi) ;
00261 bvect_cart.set_rot_phi(rot_phi) ;
00262
00263 reset_coord() ;
00264
00265 }
00266
00267
00268
00269 void Map::reset_coord() {
00270
00271
00272 r.del_t() ;
00273 tet.del_t() ;
00274 phi.del_t() ;
00275 sint.del_t() ;
00276 cost.del_t() ;
00277 sinp.del_t() ;
00278 cosp.del_t() ;
00279
00280
00281 x.del_t() ;
00282 y.del_t() ;
00283 z.del_t() ;
00284
00285
00286 xa.del_t() ;
00287 ya.del_t() ;
00288 za.del_t() ;
00289 }
00290
00291
00292
00293
00294
00295 void Map::convert_absolute(double xx, double yy, double zz,
00296 double& rr, double& theta, double& pphi) const {
00297
00298
00299
00300 double x1 = xx - ori_x ;
00301 double y1 = yy - ori_y ;
00302 double z1 = zz - ori_z ;
00303
00304
00305 double rho2 = x1*x1 + y1*y1 ;
00306 double rho = sqrt( rho2 ) ;
00307 rr = sqrt(rho2 + z1*z1) ;
00308 theta = atan2(rho, z1) ;
00309 pphi = atan2(y1, x1) - rot_phi ;
00310 if (pphi < 0) pphi += 2*M_PI ;
00311
00312 }
00313
00314 const Metric_flat& Map::flat_met_spher() const {
00315
00316 if (p_flat_met_spher == 0x0) {
00317 p_flat_met_spher = new Metric_flat(*this, bvect_spher) ;
00318 }
00319
00320 return *p_flat_met_spher ;
00321
00322 }
00323
00324 const Metric_flat& Map::flat_met_cart() const {
00325
00326 if (p_flat_met_cart == 0x0) {
00327 p_flat_met_cart = new Metric_flat(*this, bvect_cart) ;
00328 }
00329
00330 return *p_flat_met_cart ;
00331
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343