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

Last change on this file since 2763 was 2322, checked in by cmv, 23 years ago
  • passage xxstream.h en xxstream
  • compile avec gcc_3.2, gcc_2.96 et cxx En 3.2 le seek from ::end semble marcher (voir Eval/COS/pbseekios.cc)

rz+cmv 11/2/2003

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