Last change
on this file since 461 was 262, checked in by ansari, 26 years ago |
Ajout de fichiers de calcul de geometrie Vector3d, UnitVector, Circle, de Benoit Revenu Reza 23/04/99
|
File size:
1.1 KB
|
Rev | Line | |
---|
[262] | 1 | #include "longlat.h"
|
---|
| 2 |
|
---|
| 3 | LongLat::LongLat()
|
---|
| 4 | {
|
---|
| 5 | _lon=0.;
|
---|
| 6 | _lat=0.;
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | LongLat::LongLat(double longitude, double latitude)
|
---|
| 10 | {
|
---|
| 11 | _lon=mod(longitude,pi2);
|
---|
| 12 | if( latitude == pi_over_2 ) _lat=latitude;
|
---|
| 13 | else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | LongLat::LongLat(double x, double y, double z)
|
---|
| 17 | {
|
---|
| 18 | double norm=sqrt(x*x+y*y+z*z);
|
---|
| 19 | double theta;
|
---|
| 20 | if( norm != 0. )
|
---|
| 21 | {
|
---|
| 22 | theta=acos(z/norm); // dans [0,Pi]
|
---|
| 23 | if( mod(theta,M_PI) == 0. ) _lon=0.; // on est sur +-Oz, le vecteur z est en phi=0
|
---|
| 24 | // else _lon=acos(x/sin(theta)/norm)+M_PI*(y<0);
|
---|
| 25 | else _lon=scangle(y/sin(theta)/norm,x/sin(theta)/norm);
|
---|
| 26 | }
|
---|
| 27 | else // vecteur nul
|
---|
| 28 | {
|
---|
| 29 | theta=0.;
|
---|
| 30 | _lon=0.;
|
---|
| 31 | }
|
---|
| 32 | _lat=pi_over_2-theta;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | void LongLat::Set(double longitude, double latitude)
|
---|
| 36 | {
|
---|
| 37 | _lon=mod(longitude,pi2);
|
---|
| 38 | if( latitude == pi_over_2 ) _lat=latitude;
|
---|
| 39 | else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | void LongLat::Print(ostream& os) const
|
---|
| 43 | {
|
---|
| 44 | os << "LongLat : longitude = " << _lon << " phi = " << this->Phi() << endl;
|
---|
| 45 | os << "LongLat : latitude = " << _lat << " theta = " << this->Theta() << endl;
|
---|
| 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.