3 // ---------------------------------------------------------------------------
5 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
7 // This is the definitions of the inline member functions of the
13 // Put commonly used accessors as early as possible to avoid inlining misses:
15 inline double HepRotation::xx() const { return rxx; }
16 inline double HepRotation::xy() const { return rxy; }
17 inline double HepRotation::xz() const { return rxz; }
18 inline double HepRotation::yx() const { return ryx; }
19 inline double HepRotation::yy() const { return ryy; }
20 inline double HepRotation::yz() const { return ryz; }
21 inline double HepRotation::zx() const { return rzx; }
22 inline double HepRotation::zy() const { return rzy; }
23 inline double HepRotation::zz() const { return rzz; }
25 inline HepRep3x3 HepRotation::rep3x3() const {
26 return HepRep3x3 ( rxx, rxy, rxz,
31 inline double HepRotation::xt() const { return 0.0; }
32 inline double HepRotation::yt() const { return 0.0; }
33 inline double HepRotation::zt() const { return 0.0; }
34 inline double HepRotation::tx() const { return 0.0; }
35 inline double HepRotation::ty() const { return 0.0; }
36 inline double HepRotation::tz() const { return 0.0; }
37 inline double HepRotation::tt() const { return 1.0; }
39 inline HepRep4x4 HepRotation::rep4x4() const {
40 return HepRep4x4 ( rxx, rxy, rxz, 0.0,
48 inline HepRotation::HepRotation() : rxx(1.0), rxy(0.0), rxz(0.0),
49 ryx(0.0), ryy(1.0), ryz(0.0),
50 rzx(0.0), rzy(0.0), rzz(1.0) {}
52 inline HepRotation::HepRotation(const HepRotation & m1) :
53 rxx(m1.rxx), rxy(m1.rxy), rxz(m1.rxz),
54 ryx(m1.ryx), ryy(m1.ryy), ryz(m1.ryz),
55 rzx(m1.rzx), rzy(m1.rzy), rzz(m1.rzz) {}
57 inline HepRotation::HepRotation
58 (double mxx, double mxy, double mxz,
59 double myx, double myy, double myz,
60 double mzx, double mzy, double mzz) :
61 rxx(mxx), rxy(mxy), rxz(mxz),
62 ryx(myx), ryy(myy), ryz(myz),
63 rzx(mzx), rzy(mzy), rzz(mzz) {}
65 inline HepRotation::HepRotation ( const HepRep3x3 & m1 ) :
66 rxx(m1.xx_), rxy(m1.xy_), rxz(m1.xz_),
67 ryx(m1.yx_), ryy(m1.yy_), ryz(m1.yz_),
68 rzx(m1.zx_), rzy(m1.zy_), rzz(m1.zz_) {}
70 inline HepRotation::HepRotation(const HepRotationX & rx) :
71 rxx(1.0), rxy(0.0), rxz(0.0),
72 ryx(0.0), ryy(rx.yy()), ryz(rx.yz()),
73 rzx(0.0), rzy(rx.zy()), rzz(rx.zz()) {}
75 inline HepRotation::HepRotation(const HepRotationY & ry) :
76 rxx(ry.xx()), rxy(0.0), rxz(ry.xz()),
77 ryx(0.0), ryy(1.0), ryz(0.0),
78 rzx(ry.zx()), rzy(0.0), rzz(ry.zz()) {}
80 inline HepRotation::HepRotation(const HepRotationZ & rz) :
81 rxx(rz.xx()), rxy(rz.xy()), rxz(0.0),
82 ryx(rz.yx()), ryy(rz.yy()), ryz(0.0),
83 rzx(0.0), rzy(0.0), rzz(1.0) {}
85 inline HepRotation::~HepRotation() {}
89 inline HepRotation::HepRotation_row::HepRotation_row
90 (const HepRotation & r, int i) : rr(r), ii(i) {}
92 inline double HepRotation::HepRotation_row::operator [] (int jj) const {
97 const HepRotation::HepRotation_row HepRotation::operator [] (int i) const {
98 return HepRotation_row(*this, i);
101 inline Hep3Vector HepRotation::colX() const
102 { return Hep3Vector ( rxx, ryx, rzx ); }
103 inline Hep3Vector HepRotation::colY() const
104 { return Hep3Vector ( rxy, ryy, rzy ); }
105 inline Hep3Vector HepRotation::colZ() const
106 { return Hep3Vector ( rxz, ryz, rzz ); }
108 inline Hep3Vector HepRotation::rowX() const
109 { return Hep3Vector ( rxx, rxy, rxz ); }
110 inline Hep3Vector HepRotation::rowY() const
111 { return Hep3Vector ( ryx, ryy, ryz ); }
112 inline Hep3Vector HepRotation::rowZ() const
113 { return Hep3Vector ( rzx, rzy, rzz ); }
115 inline HepLorentzVector HepRotation::col1() const
116 { return HepLorentzVector (colX(), 0); }
117 inline HepLorentzVector HepRotation::col2() const
118 { return HepLorentzVector (colY(), 0); }
119 inline HepLorentzVector HepRotation::col3() const
120 { return HepLorentzVector (colZ(), 0); }
121 inline HepLorentzVector HepRotation::col4() const
122 { return HepLorentzVector (0,0,0,1); }
123 inline HepLorentzVector HepRotation::row1() const
124 { return HepLorentzVector (rowX(), 0); }
125 inline HepLorentzVector HepRotation::row2() const
126 { return HepLorentzVector (rowY(), 0); }
127 inline HepLorentzVector HepRotation::row3() const
128 { return HepLorentzVector (rowZ(), 0); }
129 inline HepLorentzVector HepRotation::row4() const
130 { return HepLorentzVector (0,0,0,1); }
132 inline double HepRotation::getPhi () const { return phi(); }
133 inline double HepRotation::getTheta() const { return theta(); }
134 inline double HepRotation::getPsi () const { return psi(); }
135 inline double HepRotation::getDelta() const { return delta(); }
136 inline Hep3Vector HepRotation::getAxis () const { return axis(); }
138 inline HepRotation & HepRotation::operator = (const HepRotation & m1) {
151 inline HepRotation & HepRotation::set(const HepRep3x3 & m1) {
164 inline HepRotation & HepRotation::set(const HepRotationX & r) {
165 return (set (r.rep3x3()));
167 inline HepRotation & HepRotation::set(const HepRotationY & r) {
168 return (set (r.rep3x3()));
170 inline HepRotation & HepRotation::set(const HepRotationZ & r) {
171 return (set (r.rep3x3()));
174 inline HepRotation & HepRotation::operator= (const HepRotationX & r) {
175 return (set (r.rep3x3()));
177 inline HepRotation & HepRotation::operator= (const HepRotationY & r) {
178 return (set (r.rep3x3()));
180 inline HepRotation & HepRotation::operator= (const HepRotationZ & r) {
181 return (set (r.rep3x3()));
184 inline Hep3Vector HepRotation::operator * (const Hep3Vector & p) const {
185 return Hep3Vector(rxx*p.x() + rxy*p.y() + rxz*p.z(),
186 ryx*p.x() + ryy*p.y() + ryz*p.z(),
187 rzx*p.x() + rzy*p.y() + rzz*p.z());
188 // This is identical to the code in the CLHEP 1.6 version
191 inline Hep3Vector HepRotation::operator () (const Hep3Vector & p) const {
192 register double x = p.x();
193 register double y = p.y();
194 register double z = p.z();
195 return Hep3Vector(rxx*x + rxy*y + rxz*z,
196 ryx*x + ryy*y + ryz*z,
197 rzx*x + rzy*y + rzz*z);
200 inline HepLorentzVector
201 HepRotation::operator () (const HepLorentzVector & w) const {
202 return HepLorentzVector( operator() (w.vect()), w.t() );
205 inline HepLorentzVector HepRotation::operator *
206 (const HepLorentzVector & p) const {
207 return operator()(p);
210 inline HepRotation HepRotation::operator* (const HepRotation & r) const {
211 return HepRotation(rxx*r.rxx + rxy*r.ryx + rxz*r.rzx,
212 rxx*r.rxy + rxy*r.ryy + rxz*r.rzy,
213 rxx*r.rxz + rxy*r.ryz + rxz*r.rzz,
214 ryx*r.rxx + ryy*r.ryx + ryz*r.rzx,
215 ryx*r.rxy + ryy*r.ryy + ryz*r.rzy,
216 ryx*r.rxz + ryy*r.ryz + ryz*r.rzz,
217 rzx*r.rxx + rzy*r.ryx + rzz*r.rzx,
218 rzx*r.rxy + rzy*r.ryy + rzz*r.rzy,
219 rzx*r.rxz + rzy*r.ryz + rzz*r.rzz );
222 inline HepRotation HepRotation::operator * (const HepRotationX & rx) const {
223 double yy1 = rx.yy();
224 double yz1 = rx.yz();
228 rxx, rxy*yy1 + rxz*zy1, rxy*yz1 + rxz*zz1,
229 ryx, ryy*yy1 + ryz*zy1, ryy*yz1 + ryz*zz1,
230 rzx, rzy*yy1 + rzz*zy1, rzy*yz1 + rzz*zz1 );
233 inline HepRotation HepRotation::operator * (const HepRotationY & ry) const {
234 double xx1 = ry.xx();
235 double xz1 = ry.xz();
239 rxx*xx1 + rxz*zx1, rxy, rxx*xz1 + rxz*zz1,
240 ryx*xx1 + ryz*zx1, ryy, ryx*xz1 + ryz*zz1,
241 rzx*xx1 + rzz*zx1, rzy, rzx*xz1 + rzz*zz1 );
244 inline HepRotation HepRotation::operator * (const HepRotationZ & rz) const {
245 double xx1 = rz.xx();
246 double xy1 = rz.xy();
250 rxx*xx1 + rxy*yx1, rxx*xy1 + rxy*yy1, rxz,
251 ryx*xx1 + ryy*yx1, ryx*xy1 + ryy*yy1, ryz,
252 rzx*xx1 + rzy*yx1, rzx*xy1 + rzy*yy1, rzz );
256 inline HepRotation & HepRotation::operator *= (const HepRotation & r) {
257 return *this = (*this) * (r);
260 inline HepRotation & HepRotation::operator *= (const HepRotationX & r) {
261 return *this = (*this) * (r); }
262 inline HepRotation & HepRotation::operator *= (const HepRotationY & r) {
263 return *this = (*this) * (r); }
264 inline HepRotation & HepRotation::operator *= (const HepRotationZ & r) {
265 return *this = (*this) * (r); }
267 inline HepRotation & HepRotation::transform(const HepRotation & r) {
268 return *this = r * (*this);
271 inline HepRotation & HepRotation::transform(const HepRotationX & r) {
272 return *this = r * (*this); }
273 inline HepRotation & HepRotation::transform(const HepRotationY & r) {
274 return *this = r * (*this); }
275 inline HepRotation & HepRotation::transform(const HepRotationZ & r) {
276 return *this = r * (*this); }
278 inline HepRotation HepRotation::inverse() const {
279 return HepRotation( rxx, ryx, rzx,
284 inline HepRotation inverseOf (const HepRotation & r) {
288 inline HepRotation & HepRotation::invert() {
289 return *this=inverse();
292 inline HepRotation & HepRotation::rotate
293 (double ddelta, const Hep3Vector * p) {
294 return rotate(ddelta, *p);
297 inline bool HepRotation::operator== ( const HepRotation & r ) const {
298 return ( rxx==r.rxx && rxy==r.rxy && rxz==r.rxz &&
299 ryx==r.ryx && ryy==r.ryy && ryz==r.ryz &&
300 rzx==r.rzx && rzy==r.rzy && rzz==r.rzz );
302 inline bool HepRotation::operator!= ( const HepRotation & r ) const {
303 return ! operator==(r);
305 inline bool HepRotation::operator< ( const HepRotation & r ) const
306 { return compare(r)< 0; }
307 inline bool HepRotation::operator<=( const HepRotation & r ) const
308 { return compare(r)<=0; }
309 inline bool HepRotation::operator>=( const HepRotation & r ) const
310 { return compare(r)>=0; }
311 inline bool HepRotation::operator> ( const HepRotation & r ) const
312 { return compare(r)> 0; }
314 inline double HepRotation::getTolerance() {
315 return Hep4RotationInterface::tolerance;
317 inline double HepRotation::setTolerance(double tol) {
318 return Hep4RotationInterface::setTolerance(tol);
321 inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r){
322 HepRep3x3 mmm = r.rep3x3();
325 return HepRotation ( mmm.xx_, mmm.xy_, mmm.xz_,
326 c*mmm.yx_-ss*mmm.zx_, c*mmm.yy_-ss*mmm.zy_, c*mmm.yz_-ss*mmm.zz_,
327 ss*mmm.yx_+c*mmm.zx_, ss*mmm.yy_+c*mmm.zy_, ss*mmm.yz_+c*mmm.zz_ );
330 inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r){
331 HepRep3x3 mmm = r.rep3x3();
334 return HepRotation ( c*mmm.xx_+ss*mmm.zx_, c*mmm.xy_+ss*mmm.zy_, c*mmm.xz_+ss*mmm.zz_,
335 mmm.yx_, mmm.yy_, mmm.yz_,
336 -ss*mmm.xx_+c*mmm.zx_,-ss*mmm.xy_+c*mmm.zy_,-ss*mmm.xz_+c*mmm.zz_ );
339 inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r){
340 HepRep3x3 mmm = r.rep3x3();
343 return HepRotation ( c*mmm.xx_-ss*mmm.yx_, c*mmm.xy_-ss*mmm.yy_, c*mmm.xz_-ss*mmm.yz_,
344 ss*mmm.xx_+c*mmm.yx_, ss*mmm.xy_+c*mmm.yy_, ss*mmm.xz_+c*mmm.yz_,
345 mmm.zx_, mmm.zy_, mmm.zz_ );