source: Sophya/trunk/SophyaLib/SkyMap/longlat.cc@ 2615

Last change on this file since 2615 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

File size: 1.6 KB
Line 
1#include "sopnamsp.h"
2#include "longlat.h"
3//++
4// Class LongLat
5//
6// include longlat.h
7//
8// translation from coordinates (longitude, latitude)
9// to theta,phi
10//
11// longitude=phi
12//
13// latitude=Pi/2-theta
14//
15//--
16//++
17// Titre Constructors
18//--
19//++
20LongLat::LongLat()
21//
22//--
23{
24 _lon=0.;
25 _lat=0.;
26}
27//++
28LongLat::LongLat(double longitude, double latitude)
29//
30//--
31{
32 _lon=mod(longitude,pi2);
33 if( latitude == pi_over_2 ) _lat=latitude;
34 else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
35}
36//++
37LongLat::LongLat(double x, double y, double z)
38//
39//--
40{
41 double norm=sqrt(x*x+y*y+z*z);
42 double theta;
43 if( norm != 0. )
44 {
45 theta=acos(z/norm); // dans [0,Pi]
46 if( mod(theta,M_PI) == 0. ) _lon=0.; // on est sur +-Oz, le vecteur z est en phi=0
47 // else _lon=acos(x/sin(theta)/norm)+M_PI*(y<0);
48 else _lon=scangle(y/sin(theta)/norm,x/sin(theta)/norm);
49 }
50 else // vecteur nul
51 {
52 theta=0.;
53 _lon=0.;
54 }
55 _lat=pi_over_2-theta;
56}
57//++
58// Titre Public Methods
59//--
60//++
61void LongLat::Set(double longitude, double latitude)
62//
63//--
64{
65 _lon=mod(longitude,pi2);
66 if( latitude == pi_over_2 ) _lat=latitude;
67 else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
68}
69//++
70void LongLat::Print(ostream& os) const
71//
72//--
73{
74 os << "LongLat : longitude = " << _lon << " phi = " << this->Phi() << endl;
75 os << "LongLat : latitude = " << _lat << " theta = " << this->Theta() << endl;
76}
77//++
78//
79// double Longitude() const
80// double Phi() const
81// double Latitude()
82// double Theta() const
83//--
Note: See TracBrowser for help on using the repository browser.