Geant4-11
RotationY.icc
Go to the documentation of this file.
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 its_c; }
16inline double HepRotationY::xz() const { return its_s; }
17inline double HepRotationY::zx() const { return -its_s; }
18inline double HepRotationY::zz() const { return its_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 ( its_c, 0.0, its_s,
28 0.0, 1.0, 0.0,
29 -its_s, 0.0, its_c );
30}
31
32inline HepRotationY::HepRotationY() : its_d(0.0), its_s(0.0), its_c(1.0) {}
33
34inline HepRotationY::HepRotationY(const HepRotationY & orig) :
35 its_d(orig.its_d), its_s(orig.its_s), its_c(orig.its_c)
36{}
37
38inline HepRotationY::HepRotationY(double dd, double ss, double cc) :
39 its_d(dd), its_s(ss), its_c(cc)
40{}
41
42inline HepRotationY & HepRotationY::operator= (const HepRotationY & orig) {
43 its_d = orig.its_d;
44 its_s = orig.its_s;
45 its_c = orig.its_c;
46 return *this;
47}
48
49inline HepRotationY::~HepRotationY() {}
50
51inline Hep3Vector HepRotationY::colX() const
52 { return Hep3Vector ( its_c, 0.0, -its_s ); }
53inline Hep3Vector HepRotationY::colY() const
54 { return Hep3Vector ( 0.0, 1.0, 0.0 ); }
55inline Hep3Vector HepRotationY::colZ() const
56 { return Hep3Vector ( its_s, 0.0, its_c ); }
57
58inline Hep3Vector HepRotationY::rowX() const
59 { return Hep3Vector ( its_c, 0.0, its_s ); }
60inline Hep3Vector HepRotationY::rowY() const
61 { return Hep3Vector ( 0.0, 1.0, 0.0 ); }
62inline Hep3Vector HepRotationY::rowZ() const
63 { return Hep3Vector ( -its_s, 0.0, its_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 its_d; }
69inline Hep3Vector HepRotationY::getAxis () const { return axis(); }
70
71inline double HepRotationY::delta() const { return its_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 & ddelta, Hep3Vector & aaxis) const {
80 ddelta = its_d;
81 aaxis = getAxis();
82}
83
84inline bool HepRotationY::isIdentity() const {
85 return ( its_d==0 );
86}
87
88inline int HepRotationY::compare ( const HepRotationY & r ) const {
89 if (its_d > r.its_d) return 1; else if (its_d < r.its_d) return -1; else return 0;
90}
91
92
93inline bool HepRotationY::operator==(const HepRotationY & r) const
94 { return (its_d==r.its_d); }
95inline bool HepRotationY::operator!=(const HepRotationY & r) const
96 { return (its_d!=r.its_d); }
97inline bool HepRotationY::operator>=(const HepRotationY & r) const
98 { return (its_d>=r.its_d); }
99inline bool HepRotationY::operator<=(const HepRotationY & r) const
100 { return (its_d<=r.its_d); }
101inline bool HepRotationY::operator> (const HepRotationY & r) const
102 { return (its_d> r.its_d); }
103inline bool HepRotationY::operator< (const HepRotationY & r) const
104 { return (its_d< r.its_d); }
105
106inline void HepRotationY::rectify() {
107 its_d = proper(its_d); // Just in case!
108 its_s = std::sin(its_d);
109 its_c = std::cos(its_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 * its_c + z * its_s,
117 y,
118 z * its_c - x * its_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 & m1) {
136 return *this = (*this) * (m1);
137}
138
139inline HepRotationY & HepRotationY::transform(const HepRotationY & m1) {
140 return *this = m1 * (*this);
141}
142
143inline double HepRotationY::proper( double ddelta ) {
144 // -PI < its_d <= PI
145 if ( std::fabs(ddelta) < CLHEP::pi ) {
146 return ddelta;
147 } else {
148 double x = ddelta / (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(its_d+ry.its_d),
155 its_s*ry.its_c + its_c*ry.its_s,
156 its_c*ry.its_c - its_s*ry.its_s );
157}
158
159inline HepRotationY HepRotationY::inverse() const {
160 return HepRotationY( proper(-its_d), -its_s, its_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 ( its_c, 0.0, its_s, 0.0,
197 0.0, 1.0, 0.0, 0.0,
198 -its_s, 0.0, its_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