| 1 | #ifndef VECTOR3D_H_SEEN
 | 
|---|
| 2 | #define VECTOR3D_H_SEEN
 | 
|---|
| 3 | 
 | 
|---|
| 4 | #include <math.h>
 | 
|---|
| 5 | #include <iostream.h>
 | 
|---|
| 6 | #include <stdio.h>
 | 
|---|
| 7 | #include <string.h>
 | 
|---|
| 8 | #ifdef __MWERKS__
 | 
|---|
| 9 | #include "unixmac.h"
 | 
|---|
| 10 | #endif
 | 
|---|
| 11 | #include "longlat.h"
 | 
|---|
| 12 | 
 | 
|---|
| 13 | /*
 | 
|---|
| 14 |   Geometrie en dimension 3. 
 | 
|---|
| 15 |   Tous les calculs sont faits en radians 
 | 
|---|
| 16 |   et en coordonnees spheriques theta,phi
 | 
|---|
| 17 |   pour les rotations (angles d'Euler) ma source est 
 | 
|---|
| 18 |   "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
 | 
|---|
| 19 | */
 | 
|---|
| 20 | /*!    3-D geometry. 
 | 
|---|
| 21 | 
 | 
|---|
| 22 |     All computations are made with angles in radians and with spherical
 | 
|---|
| 23 |     coordinates theta, phi.
 | 
|---|
| 24 | 
 | 
|---|
| 25 |     Concerning Euler's angles, the reference is :
 | 
|---|
| 26 |  
 | 
|---|
| 27 |     "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
 | 
|---|
| 28 | */
 | 
|---|
| 29 | 
 | 
|---|
| 30 | class Vector3d 
 | 
|---|
| 31 | {
 | 
|---|
| 32 | 
 | 
|---|
| 33 |  public:
 | 
|---|
| 34 |   
 | 
|---|
| 35 |   Vector3d();
 | 
|---|
| 36 |   Vector3d(double x, double y, double z);
 | 
|---|
| 37 |   Vector3d(double theta, double phi);
 | 
|---|
| 38 |   Vector3d(const LongLat&);
 | 
|---|
| 39 |   Vector3d(const Vector3d&);
 | 
|---|
| 40 | 
 | 
|---|
| 41 | //   To manipulate the vector
 | 
|---|
| 42 |   virtual void Setxyz(double x, double y, double z);
 | 
|---|
| 43 |   virtual void SetThetaPhi(double theta,  double phi);
 | 
|---|
| 44 |   virtual void ThetaPhi2xyz();
 | 
|---|
| 45 |   virtual void xyz2ThetaPhi();
 | 
|---|
| 46 | 
 | 
|---|
| 47 | // Acces to coordinates
 | 
|---|
| 48 |   inline double Theta() const {return _theta;}
 | 
|---|
| 49 |   inline double Phi() const {return _phi;}
 | 
|---|
| 50 |   inline double X() const {return _x;}
 | 
|---|
| 51 |   inline double Y() const {return _y;}
 | 
|---|
| 52 |   inline double Z() const {return _z;}
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   virtual Vector3d& Normalize();
 | 
|---|
| 55 |   virtual double Norm() const;
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   // produit scalaire
 | 
|---|
| 58 |   virtual double Psc(const Vector3d&) const;
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   // ecart angulaire entre 2 vecteurs dans [0,Pi]
 | 
|---|
| 61 |   /*!   angular gap between 2 vectors in [0,Pi] */
 | 
|---|
| 62 |   virtual double SepAngle(const Vector3d&) const;
 | 
|---|
| 63 | 
 | 
|---|
| 64 |   // produit vectoriel
 | 
|---|
| 65 |   /*!    vector product */
 | 
|---|
| 66 |   virtual Vector3d Vect(const Vector3d&) const;
 | 
|---|
| 67 | 
 | 
|---|
| 68 |   // vecteur perpendiculaire de meme phi
 | 
|---|
| 69 |   /*!    perpendicular vector, with equal phi */
 | 
|---|
| 70 |   virtual Vector3d VperpPhi() const;
 | 
|---|
| 71 | 
 | 
|---|
| 72 |   // vecteur perpendiculaire de meme theta
 | 
|---|
| 73 |   /*!    perpendicular vector with equal theta */
 | 
|---|
| 74 |   virtual Vector3d VperpTheta() const;
 | 
|---|
| 75 | 
 | 
|---|
| 76 |   virtual Vector3d ETheta() const;
 | 
|---|
| 77 |   virtual Vector3d EPhi() const;
 | 
|---|
| 78 | 
 | 
|---|
| 79 |   // rotations d'Euler
 | 
|---|
| 80 |   /*!    Euler's rotations */
 | 
|---|
| 81 |   // rotations d Euler
 | 
|---|
| 82 |   virtual Vector3d Euler(double, double, double) const;
 | 
|---|
| 83 | 
 | 
|---|
| 84 |   // rotation inverse
 | 
|---|
| 85 |   /*!    inverse rotation */
 | 
|---|
| 86 |   Vector3d InvEuler(double, double, double) const;
 | 
|---|
| 87 | 
 | 
|---|
| 88 |   // rotation d'angle phi autour d'un axe omega (regle du tire-bouchon)
 | 
|---|
| 89 |   /*!    rotation of angle phi around an axis omega (Maxwell's rule) */
 | 
|---|
| 90 |   Vector3d Rotate(const Vector3d& omega,double phi) const;
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   /*virtual*/ Vector3d& operator=(const Vector3d&); // $CHECK$ EA 101299
 | 
|---|
| 93 |   virtual Vector3d& operator+=(const Vector3d&);
 | 
|---|
| 94 |   virtual Vector3d& operator-=(const Vector3d&);
 | 
|---|
| 95 |   virtual Vector3d operator+(const Vector3d&) const;
 | 
|---|
| 96 |   virtual Vector3d operator-(const Vector3d&) const;
 | 
|---|
| 97 | 
 | 
|---|
| 98 |   virtual Vector3d& operator+=(double);
 | 
|---|
| 99 |   virtual Vector3d& operator/=(double);
 | 
|---|
| 100 |   virtual Vector3d& operator*=(double);
 | 
|---|
| 101 | 
 | 
|---|
| 102 |   virtual Vector3d operator+(double) const;
 | 
|---|
| 103 |   virtual Vector3d operator-(double) const;
 | 
|---|
| 104 |   virtual Vector3d operator*(double) const;
 | 
|---|
| 105 |   virtual Vector3d operator/(double) const;
 | 
|---|
| 106 | 
 | 
|---|
| 107 |   /*!    vector product */
 | 
|---|
| 108 |   virtual Vector3d operator^(const Vector3d&) const; // produit vectoriel
 | 
|---|
| 109 |   /*!    dot product */
 | 
|---|
| 110 |   virtual double operator*(const Vector3d&) const; // produit scalaire
 | 
|---|
| 111 | 
 | 
|---|
| 112 |   bool operator==(const Vector3d&);
 | 
|---|
| 113 |   
 | 
|---|
| 114 |   virtual void Print(ostream& os) const;
 | 
|---|
| 115 | 
 | 
|---|
| 116 |  protected:
 | 
|---|
| 117 | 
 | 
|---|
| 118 |   double _x;
 | 
|---|
| 119 |   double _y;
 | 
|---|
| 120 |   double _z;
 | 
|---|
| 121 |   double _theta;
 | 
|---|
| 122 |   double _phi;
 | 
|---|
| 123 | 
 | 
|---|
| 124 | };
 | 
|---|
| 125 | 
 | 
|---|
| 126 | inline ostream& operator<<(ostream& s, const Vector3d& v) 
 | 
|---|
| 127 | {  
 | 
|---|
| 128 |   v.Print(s);  
 | 
|---|
| 129 |   return s;  
 | 
|---|
| 130 | }
 | 
|---|
| 131 | 
 | 
|---|
| 132 | // fonctions globales
 | 
|---|
| 133 | 
 | 
|---|
| 134 | inline Vector3d operator*(double d, const Vector3d& v) 
 | 
|---|
| 135 | {
 | 
|---|
| 136 |   return v*d;
 | 
|---|
| 137 | }
 | 
|---|
| 138 | 
 | 
|---|
| 139 | inline Vector3d operator+(double d, const Vector3d& v) 
 | 
|---|
| 140 | {
 | 
|---|
| 141 |   return v+d;
 | 
|---|
| 142 | }
 | 
|---|
| 143 | 
 | 
|---|
| 144 | #endif
 | 
|---|
| 145 | 
 | 
|---|
| 146 | 
 | 
|---|