source: trunk/CLHEP/Vector/RotationX.icc

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

first commit

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