Line data Source code
1 : //--------------------------------------------------------------------------
2 : //
3 : // Environment:
4 : // This software is part of the EvtGen package developed jointly
5 : // for the BaBar and CLEO collaborations. If you use all or part
6 : // of it, please give an appropriate acknowledgement.
7 : //
8 : // Copyright Information: See EvtGen/COPYRIGHT
9 : // Copyright (C) 1998 Caltech, UCSB
10 : //
11 : // Module: EvtGen/EvtVector3R.hh
12 : //
13 : // Description: Class to describe real 3 vectors
14 : //
15 : // Modification history:
16 : //
17 : // RYD Sept. 5, 1997 Module created
18 : //
19 : //------------------------------------------------------------------------
20 :
21 : #ifndef EVTVECTOR3R_HH
22 : #define EVTVECTOR3R_HH
23 :
24 : #include <iosfwd>
25 :
26 0 : class EvtVector3R {
27 :
28 : friend EvtVector3R rotateEuler(const EvtVector3R& v,
29 : double phi,double theta,double ksi);
30 :
31 : inline friend EvtVector3R operator*(double c,const EvtVector3R& v2);
32 : inline friend double operator*(const EvtVector3R& v1,const EvtVector3R& v2);
33 : inline friend EvtVector3R operator+(const EvtVector3R& v1,const EvtVector3R& v2);
34 : inline friend EvtVector3R operator-(const EvtVector3R& v1,const EvtVector3R& v2);
35 : inline friend EvtVector3R operator*(const EvtVector3R& v1,double c);
36 : inline friend EvtVector3R operator/(const EvtVector3R& v1,double c);
37 : friend EvtVector3R cross(const EvtVector3R& v1,const EvtVector3R& v2);
38 :
39 : public:
40 : EvtVector3R();
41 : EvtVector3R(double x,double y ,double z);
42 : virtual ~EvtVector3R();
43 : inline EvtVector3R& operator*=(const double c);
44 : inline EvtVector3R& operator/=(const double c);
45 : inline EvtVector3R& operator+=(const EvtVector3R& v2);
46 : inline EvtVector3R& operator-=(const EvtVector3R& v2);
47 : inline void set(int i,double d);
48 : inline void set(double x,double y ,double z);
49 : void applyRotateEuler(double phi,double theta,double ksi);
50 : inline double get(int i) const;
51 : friend std::ostream& operator<<(std::ostream& s,const EvtVector3R& v);
52 : double dot(const EvtVector3R& v2);
53 : double d3mag() const;
54 :
55 : private:
56 :
57 : double v[3];
58 :
59 : };
60 :
61 : inline EvtVector3R& EvtVector3R::operator*=(const double c){
62 :
63 : v[0]*=c;
64 : v[1]*=c;
65 : v[2]*=c;
66 : return *this;
67 : }
68 :
69 : inline EvtVector3R& EvtVector3R::operator/=(const double c){
70 :
71 0 : v[0]/=c;
72 0 : v[1]/=c;
73 0 : v[2]/=c;
74 0 : return *this;
75 : }
76 :
77 : inline EvtVector3R& EvtVector3R::operator+=(const EvtVector3R& v2){
78 :
79 : v[0]+=v2.v[0];
80 : v[1]+=v2.v[1];
81 : v[2]+=v2.v[2];
82 : return *this;
83 : }
84 :
85 : inline EvtVector3R& EvtVector3R::operator-=(const EvtVector3R& v2){
86 :
87 : v[0]-=v2.v[0];
88 : v[1]-=v2.v[1];
89 : v[2]-=v2.v[2];
90 : return *this;
91 : }
92 :
93 : inline EvtVector3R operator*(double c,const EvtVector3R& v2){
94 :
95 : return EvtVector3R(v2)*=c;
96 : }
97 :
98 : inline EvtVector3R operator*(const EvtVector3R& v1,double c){
99 :
100 : return EvtVector3R(v1)*=c;
101 : }
102 :
103 : inline EvtVector3R operator/(const EvtVector3R& v1,double c){
104 :
105 0 : return EvtVector3R(v1)/=c;
106 : }
107 :
108 : inline double operator*(const EvtVector3R& v1,const EvtVector3R& v2){
109 :
110 : return v1.v[0]*v2.v[0]+v1.v[1]*v2.v[1]+v1.v[2]*v2.v[2];
111 : }
112 :
113 : inline EvtVector3R operator+(const EvtVector3R& v1,const EvtVector3R& v2) {
114 :
115 : return EvtVector3R(v1)+=v2;
116 : }
117 :
118 : inline EvtVector3R operator-(const EvtVector3R& v1,const EvtVector3R& v2) {
119 :
120 : return EvtVector3R(v1)-=v2;
121 :
122 : }
123 :
124 : inline double EvtVector3R::get(int i) const {
125 0 : return v[i];
126 : }
127 :
128 : inline void EvtVector3R::set(int i,double d){
129 :
130 : v[i]=d;
131 : }
132 :
133 : inline void EvtVector3R::set(double x,double y, double z){
134 :
135 : v[0]=x;
136 : v[1]=y;
137 : v[2]=z;
138 : }
139 :
140 : #endif
141 :
|