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 base_vect_spher_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_spher.C,v 1.5 2002/10/16 14:36:31 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 #include <math.h>
00083 #include <stdlib.h>
00084
00085
00086 #include "base_vect.h"
00087 #include "tenseur.h"
00088 #include "utilitaires.h"
00089
00090
00091
00092
00093
00094
00095
00096 Base_vect_spher::Base_vect_spher(double xa0, double ya0, double za0,
00097 double rot_phi_i)
00098 : ori_x(xa0),
00099 ori_y(ya0),
00100 ori_z(za0),
00101 rot_phi(rot_phi_i) {}
00102
00103
00104
00105
00106
00107
00108
00109 Base_vect_spher::Base_vect_spher(double xa0, double ya0, double za0,
00110 double rot_phi_i, const char* name_i)
00111 : Base_vect(name_i),
00112 ori_x(xa0),
00113 ori_y(ya0),
00114 ori_z(za0),
00115 rot_phi(rot_phi_i) {}
00116
00117
00118
00119 Base_vect_spher::Base_vect_spher(const Base_vect_spher& bi)
00120 : Base_vect(bi),
00121 ori_x(bi.ori_x),
00122 ori_y(bi.ori_y),
00123 ori_z(bi.ori_z),
00124 rot_phi(bi.rot_phi) {}
00125
00126
00127
00128 Base_vect_spher::Base_vect_spher(FILE* fich)
00129 : Base_vect(fich) {
00130
00131 fread_be(&ori_x, sizeof(double), 1, fich) ;
00132 fread_be(&ori_y, sizeof(double), 1, fich) ;
00133 fread_be(&ori_z, sizeof(double), 1, fich) ;
00134 fread_be(&rot_phi, sizeof(double), 1, fich) ;
00135
00136 }
00137
00138
00139
00140
00141
00142
00143 Base_vect_spher::~Base_vect_spher(){
00144
00145
00146
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 void Base_vect_spher::operator=(const Base_vect_spher& bi) {
00156
00157 set_name(bi.name) ;
00158
00159 ori_x = bi.ori_x ;
00160 ori_y = bi.ori_y ;
00161 ori_z = bi.ori_z ;
00162 rot_phi = bi.rot_phi ;
00163
00164 }
00165
00166
00167
00168 void Base_vect_spher::set_ori(double xa0, double ya0, double za0) {
00169
00170 ori_x = xa0 ;
00171 ori_y = ya0 ;
00172 ori_z = za0 ;
00173
00174 }
00175
00176
00177 void Base_vect_spher::set_rot_phi(double rot_phi_i) {
00178
00179 rot_phi = rot_phi_i ;
00180
00181 }
00182
00183
00184
00185
00186
00187
00188 bool Base_vect_spher::operator==(const Base_vect& bi) const {
00189
00190 bool resu = true ;
00191
00192 if ( bi.identify() != identify() ) {
00193
00194 resu = false ;
00195 }
00196 else{
00197
00198 const Base_vect_spher& bis = dynamic_cast<const Base_vect_spher&>( bi ) ;
00199
00200 if (bis.ori_x != ori_x) {
00201 cout
00202 << "The two Base_vect_spher have different X origin : " << ori_x
00203 << " <-> " << bis.ori_x << endl ;
00204 resu = false ;
00205 }
00206
00207 if (bis.ori_y != ori_y) {
00208 cout
00209 << "The two Base_vect_spher have different Y origin : " << ori_y
00210 << " <-> " << bis.ori_y << endl ;
00211 resu = false ;
00212 }
00213
00214 if (bis.ori_z != ori_z) {
00215 cout
00216 << "The two Base_vect_spher have different Z origin : " << ori_z
00217 << " <-> " << bis.ori_z << endl ;
00218 resu = false ;
00219 }
00220
00221 if (bis.rot_phi != rot_phi) {
00222 cout
00223 << "The two Base_vect_spher have different rot_phi : " << rot_phi
00224 << " <-> " << bis.rot_phi << endl ;
00225 resu = false ;
00226 }
00227
00228
00229 }
00230
00231 return resu ;
00232
00233 }
00234
00235
00236
00237
00238
00239 void Base_vect_spher::sauve(FILE* fich) const {
00240
00241 Base_vect::sauve(fich) ;
00242
00243 fwrite_be(&ori_x, sizeof(double), 1, fich) ;
00244 fwrite_be(&ori_y, sizeof(double), 1, fich) ;
00245 fwrite_be(&ori_z, sizeof(double), 1, fich) ;
00246 fwrite_be(&rot_phi, sizeof(double), 1, fich) ;
00247
00248 }
00249
00250 ostream& Base_vect_spher::operator>>(ostream & ost) const {
00251
00252 ost << "Absolute coordinates (X,Y,Z) of the origin : "
00253 << ori_x << " " << ori_y << " " << ori_z << endl ;
00254 ost << "Azimuthal angle with respect to the Absolute frame : "
00255 << rot_phi << endl ;
00256
00257 return ost ;
00258
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 void Base_vect_spher::change_basis(Tenseur& ti) const {
00270
00271
00272 assert(ti.get_etat() != ETATNONDEF) ;
00273
00274 const Base_vect* triad_i = ti.get_triad() ;
00275
00276 assert(triad_i != 0x0) ;
00277
00278 if (ti.get_etat() == ETATZERO) {
00279 ti.set_triad(*this) ;
00280 return ;
00281 }
00282
00283 assert(ti.get_etat() == ETATQCQ) ;
00284
00285 const Base_vect_cart* bvc = dynamic_cast<const Base_vect_cart*>(triad_i) ;
00286 const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad_i) ;
00287
00288
00289
00290
00291 if (bvc != 0x0) {
00292 assert(bvs == 0x0) ;
00293
00294 switch (ti.get_valence()) {
00295
00296 case 1 : {
00297
00298
00299
00300 const Map* mp = ti.get_mp() ;
00301 assert( *this == mp->get_bvect_spher() ) ;
00302 assert( *bvc == mp->get_bvect_cart() ) ;
00303
00304 Cmp vx = ti(0) ;
00305 Cmp vy = ti(1) ;
00306 Cmp vz = ti(2) ;
00307
00308 mp->comp_r_from_cartesian(vx, vy, vz, ti.set(0)) ;
00309 mp->comp_t_from_cartesian(vx, vy, vz, ti.set(1)) ;
00310 mp->comp_p_from_cartesian(vx, vy, ti.set(2)) ;
00311
00312 break ;
00313 }
00314
00315 case 2 : {
00316
00317
00318
00319 const Map* mp = ti.get_mp() ;
00320 assert( *this == mp->get_bvect_spher() ) ;
00321 assert( *bvc == mp->get_bvect_cart() ) ;
00322
00323 for (int i=0; i<2; i++)
00324 assert(ti.get_type_indice(i) == COV) ;
00325
00326
00327
00328 Tenseur tmp(*mp, 2, COV, *this) ;
00329 tmp.allocate_all() ;
00330 for (int i=0; i<3; i++) {
00331 mp->comp_r_from_cartesian(ti(0,i), ti(1,i), ti(2,i)
00332 , tmp.set(0,i) ) ;
00333 mp->comp_t_from_cartesian(ti(0,i), ti(1,i), ti(2,i)
00334 , tmp.set(1,i) ) ;
00335 mp->comp_p_from_cartesian(ti(0,i), ti(1,i), tmp.set(2,i) ) ;
00336 }
00337 for (int i=0; i<3; i++) {
00338 mp->comp_r_from_cartesian(tmp(i,0), tmp(i,1), tmp(i,2)
00339 , ti.set(i,0) ) ;
00340 mp->comp_t_from_cartesian(tmp(i,0), tmp(i,1), tmp(i,2)
00341 , ti.set(i,1) ) ;
00342 mp->comp_p_from_cartesian(tmp(i,0), tmp(i,1), ti.set(i,2) ) ;
00343 }
00344
00345
00346 break ;
00347 }
00348
00349 default : {
00350 cout <<
00351 "Base_vect_sphere::change_basis : the case of valence "
00352 << ti.get_valence() << " is not treated !" << endl ;
00353 abort() ;
00354 break ;
00355 }
00356 }
00357 }
00358
00359
00360
00361
00362
00363 if (bvs != 0x0) {
00364
00365 assert(bvc == 0x0) ;
00366
00367 cout << "Base_vect_spher::change_basis : case not treated yet !" << endl ;
00368 abort() ;
00369 }
00370
00371 ti.set_triad(*this) ;
00372 }