source: Sophya/trunk/SophyaLib/SkyMap/vector3d.h@ 3174

Last change on this file since 3174 was 2973, checked in by ansari, 19 years ago

1/ Nettoyage+commentaires/doxygen ds Vector3d, UnitVector, LongLat,
SphereCoordSys ...
2/ Ajout de la classe angle pour faciliter les conversions rad<>deg<>arcmin
dans le fichier vector3d.h .cc
3/ nettoyage/uniformisation methodes print pour pixelmap, ajout de la
methode PixelMap<T>::Show()
4/ Ajout methodes SphericalMap<T>::HasSymThetaSlice() et
GetSymThetaSliceIndex(int_4 idx) et leurs implementations pour
SphereHEALPix et SphereThetaPhi en vue de l'optimisation du calcul
transforme Ylm
5/ Ajout methode ResolToSizeIndex ds SphereThetaPhi , SphereHEALPix et
SphereECP

Reza , 20 Juin 2006

File size: 4.7 KB
Line 
1// 3-D Geometry
2// B. Revenu, G. Le Meur 2000
3// R. Ansari 2006
4// DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
5
6#ifndef VECTOR3D_H_SEEN
7#define VECTOR3D_H_SEEN
8
9#include <math.h>
10#include <iostream>
11#include <stdio.h>
12#include <string.h>
13#ifdef __MWERKS__
14#include "unixmac.h"
15#endif
16#include "longlat.h"
17
18
19namespace SOPHYA {
20
21//! Class to ease angle conversions (radian <> degree <> arcmin <> arcsec)
22class Angle {
23public:
24 enum AngleUnit { Radian, Degree, ArcMin, ArcSec };
25 //! Constructor with specification of angle value in radian
26 Angle(double val=0.) { _angrad = val; }
27 //! Constructor with specification of angle value and unit
28 Angle(double val, Angle::AngleUnit un);
29 //! Copy constructor
30 Angle(Angle const& a) { _angrad = a._angrad; }
31
32 //! Conversion to radian
33 inline double ToRadian() const { return _angrad; }
34 //! Conversion to degree
35 inline double ToDegree() const { return _angrad*_rad2deg; }
36 //! Conversion to arcmin
37 inline double ToArcMin() const { return _angrad*_rad2min; }
38 //! Conversion to arcsec
39 inline double ToArcSec() const { return _angrad*_rad2sec; }
40
41 //! return the angle value in radian
42 inline operator double () const { return _angrad; }
43
44protected:
45 double _angrad; // angle in radians
46
47 static double _deg2rad; // deg -> radian conversion factor
48 static double _rad2deg; // rad -> degree conversion factor
49 static double _rad2min; // rad -> arcmin conversion factor
50 static double _rad2sec; // rad -> arcmin conversion factor
51
52};
53
54/*
55 Geometrie en dimension 3.
56 Tous les calculs sont faits en radians
57 et en coordonnees spheriques theta,phi
58 pour les rotations (angles d'Euler) ma source est
59 B. Revenu / G. Le Meur
60 "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
61*/
62
63class Vector3d
64{
65
66 public:
67
68 Vector3d();
69 Vector3d(double x, double y, double z);
70 Vector3d(double theta, double phi);
71 Vector3d(const LongLat&);
72 Vector3d(const Vector3d&);
73
74// To manipulate the vector
75 virtual void Setxyz(double x, double y, double z);
76 virtual void SetThetaPhi(double theta, double phi);
77 virtual void ThetaPhi2xyz();
78 virtual void xyz2ThetaPhi();
79
80// Acces to coordinates
81 inline double Theta() const {return _theta;}
82 inline double Phi() const {return _phi;}
83 inline double X() const {return _x;}
84 inline double Y() const {return _y;}
85 inline double Z() const {return _z;}
86
87 virtual Vector3d& Normalize();
88 virtual double Norm() const;
89
90 // produit scalaire
91 virtual double Psc(const Vector3d&) const;
92
93 // ecart angulaire entre 2 vecteurs dans [0,Pi]
94 //! angular gap between 2 vectors in [0,Pi]
95 virtual double SepAngle(const Vector3d&) const;
96
97 // produit vectoriel
98 //! return the vector product (*this)^v2
99 virtual Vector3d Vect(const Vector3d& v2) const;
100
101 // vecteur perpendiculaire de meme phi
102 //! return the perpendicular vector, with equal phi
103 virtual Vector3d VperpPhi() const;
104
105 // vecteur perpendiculaire de meme theta
106 //! return the perpendicular vector, with equal theta
107 virtual Vector3d VperpTheta() const;
108
109 virtual Vector3d ETheta() const;
110 virtual Vector3d EPhi() const;
111
112 // rotations d'Euler
113 //! Perform Euler's rotations
114 virtual Vector3d Euler(double, double, double) const;
115
116 // rotation inverse
117 //! perform inverse Euler rotation
118 Vector3d InvEuler(double, double, double) const;
119
120 // rotation d'angle phi autour d'un axe omega (regle du tire-bouchon)
121 //! perform rotation of angle phi around an axis omega (Maxwell's rule)
122 Vector3d Rotate(const Vector3d& omega,double phi) const;
123
124 /*virtual*/ Vector3d& operator=(const Vector3d&); // $CHECK$ EA 101299
125 virtual Vector3d& operator+=(const Vector3d&);
126 virtual Vector3d& operator-=(const Vector3d&);
127 virtual Vector3d operator+(const Vector3d&) const;
128 virtual Vector3d operator-(const Vector3d&) const;
129
130 virtual Vector3d& operator+=(double);
131 virtual Vector3d& operator/=(double);
132 virtual Vector3d& operator*=(double);
133
134 virtual Vector3d operator+(double) const;
135 virtual Vector3d operator-(double) const;
136 virtual Vector3d operator*(double) const;
137 virtual Vector3d operator/(double) const;
138
139 /*! vector product */
140 virtual Vector3d operator^(const Vector3d&) const; // produit vectoriel
141 /*! dot product */
142 virtual double operator*(const Vector3d&) const; // produit scalaire
143
144 bool operator==(const Vector3d&);
145
146 virtual void Print(ostream& os) const;
147
148 protected:
149
150 double _x;
151 double _y;
152 double _z;
153 double _theta;
154 double _phi;
155
156};
157
158inline ostream& operator<<(ostream& s, const Vector3d& v)
159{
160 v.Print(s);
161 return s;
162}
163
164// fonctions globales
165
166inline Vector3d operator*(double d, const Vector3d& v)
167{
168 return v*d;
169}
170
171inline Vector3d operator+(double d, const Vector3d& v)
172{
173 return v+d;
174}
175
176
177} // namespace SOPHYA
178
179#endif
180
181
Note: See TracBrowser for help on using the repository browser.