source: trunk/CLHEP/Vector/RotationY.icc@ 14

Last change on this file since 14 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 6.8 KB
Line 
1// -*- C++ -*-
2// ---------------------------------------------------------------------------
3//
4// This file is a part of the CLHEP - a Class Library for High Energy Physics.
5//
6// This is the definitions of the inline member functions of the
7// HepRotationY class
8//
9
10#include <cmath>
11#include "CLHEP/Units/PhysicalConstants.h"
12
13namespace CLHEP {
14
15inline double HepRotationY::xx() const { return c; }
16inline double HepRotationY::xz() const { return s; }
17inline double HepRotationY::zx() const { return -s; }
18inline double HepRotationY::zz() const { return c; }
19
20inline double HepRotationY::yy() const { return 1.0; }
21inline double HepRotationY::yx() const { return 0.0; }
22inline double HepRotationY::yz() const { return 0.0; }
23inline double HepRotationY::xy() const { return 0.0; }
24inline double HepRotationY::zy() const { return 0.0; }
25
26inline HepRep3x3 HepRotationY::rep3x3() const {
27 return HepRep3x3 ( c , 0.0, s,
28 0.0, 1.0, 0.0,
29 -s , 0.0, c );
30}
31
32inline HepRotationY::HepRotationY() : d(0.0), s(0.0), c(1.0) {}
33
34inline HepRotationY::HepRotationY(const HepRotationY & orig) :
35 d(orig.d), s(orig.s), c(orig.c)
36{}
37
38inline HepRotationY::HepRotationY(double dd, double ss, double cc) :
39 d(dd), s(ss), c(cc)
40{}
41
42inline HepRotationY & HepRotationY::operator= (const HepRotationY & orig) {
43 d = orig.d;
44 s = orig.s;
45 c = orig.c;
46 return *this;
47}
48
49inline HepRotationY::~HepRotationY() {}
50
51inline Hep3Vector HepRotationY::colX() const
52 { return Hep3Vector ( c, 0.0, -s ); }
53inline Hep3Vector HepRotationY::colY() const
54 { return Hep3Vector ( 0.0, 1.0, 0.0 ); }
55inline Hep3Vector HepRotationY::colZ() const
56 { return Hep3Vector ( s, 0.0, c ); }
57
58inline Hep3Vector HepRotationY::rowX() const
59 { return Hep3Vector ( c, 0.0, s ); }
60inline Hep3Vector HepRotationY::rowY() const
61 { return Hep3Vector ( 0.0, 1.0, 0.0 ); }
62inline Hep3Vector HepRotationY::rowZ() const
63 { return Hep3Vector ( -s, 0.0, c ); }
64
65inline double HepRotationY::getPhi () const { return phi(); }
66inline double HepRotationY::getTheta() const { return theta(); }
67inline double HepRotationY::getPsi () const { return psi(); }
68inline double HepRotationY::getDelta() const { return d; }
69inline Hep3Vector HepRotationY::getAxis () const { return axis(); }
70
71inline double HepRotationY::delta() const { return d; }
72inline Hep3Vector HepRotationY::axis() const { return Hep3Vector(0,1,0); }
73
74inline HepAxisAngle HepRotationY::axisAngle() const {
75 return HepAxisAngle ( axis(), delta() );
76}
77
78inline void HepRotationY::getAngleAxis
79 (double & delta, Hep3Vector & axis) const {
80 delta = d;
81 axis = getAxis();
82}
83
84inline bool HepRotationY::isIdentity() const {
85 return ( d==0 );
86}
87
88inline int HepRotationY::compare ( const HepRotationY & r ) const {
89 if (d > r.d) return 1; else if (d < r.d) return -1; else return 0;
90}
91
92
93inline bool HepRotationY::operator==(const HepRotationY & r) const
94 { return (d==r.d); }
95inline bool HepRotationY::operator!=(const HepRotationY & r) const
96 { return (d!=r.d); }
97inline bool HepRotationY::operator>=(const HepRotationY & r) const
98 { return (d>=r.d); }
99inline bool HepRotationY::operator<=(const HepRotationY & r) const
100 { return (d<=r.d); }
101inline bool HepRotationY::operator> (const HepRotationY & r) const
102 { return (d> r.d); }
103inline bool HepRotationY::operator< (const HepRotationY & r) const
104 { return (d< r.d); }
105
106inline void HepRotationY::rectify() {
107 d = proper(d); // Just in case!
108 s = std::sin(d);
109 c = std::cos(d);
110}
111
112inline Hep3Vector HepRotationY::operator() (const Hep3Vector & p) const {
113 double x = p.x();
114 double y = p.y();
115 double z = p.z();
116 return Hep3Vector( x * c + z * s,
117 y,
118 z * c - x * s );
119}
120
121inline Hep3Vector HepRotationY::operator * (const Hep3Vector & p) const {
122 return operator()(p);
123}
124
125inline HepLorentzVector HepRotationY::operator()
126 ( const HepLorentzVector & w ) const {
127 return HepLorentzVector( operator() (w.vect()) , w.t() );
128}
129
130inline HepLorentzVector HepRotationY::operator *
131 (const HepLorentzVector & p) const {
132 return operator()(p);
133}
134
135inline HepRotationY & HepRotationY::operator *= (const HepRotationY & m) {
136 return *this = (*this) * (m);
137}
138
139inline HepRotationY & HepRotationY::transform(const HepRotationY & m) {
140 return *this = m * (*this);
141}
142
143inline double HepRotationY::proper( double delta ) {
144 // -PI < d <= PI
145 if ( std::fabs(delta) < CLHEP::pi ) {
146 return delta;
147 } else {
148 register double x = delta / (CLHEP::twopi);
149 return (CLHEP::twopi) * ( x + std::floor(.5-x) );
150 }
151} // proper()
152
153inline HepRotationY HepRotationY::operator * ( const HepRotationY & ry ) const {
154 return HepRotationY ( HepRotationY::proper(d+ry.d),
155 s*ry.c + c*ry.s,
156 c*ry.c - s*ry.s );
157}
158
159inline HepRotationY HepRotationY::inverse() const {
160 return HepRotationY( proper(-d), -s, c );
161}
162
163inline HepRotationY inverseOf(const HepRotationY & r) {
164 return r.inverse();
165}
166
167inline HepRotationY & HepRotationY::invert() {
168 return *this=inverse();
169}
170
171inline HepLorentzVector HepRotationY::col1() const
172 { return HepLorentzVector (colX(), 0); }
173inline HepLorentzVector HepRotationY::col2() const
174 { return HepLorentzVector (colY(), 0); }
175inline HepLorentzVector HepRotationY::col3() const
176 { return HepLorentzVector (colZ(), 0); }
177inline HepLorentzVector HepRotationY::col4() const
178 { return HepLorentzVector (0,0,0,1); }
179inline HepLorentzVector HepRotationY::row1() const
180 { return HepLorentzVector (rowX(), 0); }
181inline HepLorentzVector HepRotationY::row2() const
182 { return HepLorentzVector (rowY(), 0); }
183inline HepLorentzVector HepRotationY::row3() const
184 { return HepLorentzVector (rowZ(), 0); }
185inline HepLorentzVector HepRotationY::row4() const
186 { return HepLorentzVector (0,0,0,1); }
187inline double HepRotationY::xt() const { return 0.0; }
188inline double HepRotationY::yt() const { return 0.0; }
189inline double HepRotationY::zt() const { return 0.0; }
190inline double HepRotationY::tx() const { return 0.0; }
191inline double HepRotationY::ty() const { return 0.0; }
192inline double HepRotationY::tz() const { return 0.0; }
193inline double HepRotationY::tt() const { return 1.0; }
194
195inline HepRep4x4 HepRotationY::rep4x4() const {
196 return HepRep4x4 ( c , 0.0, s, 0.0,
197 0.0, 1.0, 0.0, 0.0,
198 -s , 0.0, c, 0.0,
199 0.0, 0.0, 0.0, 1.0 );
200}
201
202inline double HepRotationY::getTolerance() {
203 return Hep4RotationInterface::tolerance;
204}
205inline double HepRotationY::setTolerance(double tol) {
206 return Hep4RotationInterface::setTolerance(tol);
207}
208
209} // namespace CLHEP
Note: See TracBrowser for help on using the repository browser.