Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
RotationY.cc
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 implementation of methods of the HepRotationY class which
7// were introduced when ZOOM PhysicsVectors was merged in.
8//
9
15
16#include <cmath>
17#include <stdlib.h>
18#include <iostream>
19
20namespace CLHEP {
21
22static inline double safe_acos (double x) {
23 if (std::abs(x) <= 1.0) return std::acos(x);
24 return ( (x>0) ? 0 : CLHEP::pi );
25}
26
28 its_d(proper(ddelta)), its_s(std::sin(ddelta)), its_c(std::cos(ddelta))
29{}
30
31HepRotationY & HepRotationY::set ( double ddelta ) {
32 its_d = proper(ddelta);
33 its_s = std::sin(its_d);
34 its_c = std::cos(its_d);
35 return *this;
36}
37
38double HepRotationY::phi() const {
39 if ( its_d == 0 ) {
40 return 0;
41 } else if ( (its_d < 0) || (its_d == CLHEP::pi) ) {
42 return +CLHEP::halfpi;
43 } else {
44 return -CLHEP::halfpi;
45 }
46} // HepRotationY::phi()
47
48double HepRotationY::theta() const {
49 return std::fabs( its_d );
50} // HepRotationY::theta()
51
52double HepRotationY::psi() const {
53 if ( its_d == 0 ) {
54 return 0;
55 } else if ( (its_d < 0) || (its_d == CLHEP::pi) ) {
56 return -CLHEP::halfpi;
57 } else {
58 return +CLHEP::halfpi;
59 }
60} // HepRotationY::psi()
61
63 return HepEulerAngles( phi(), theta(), psi() );
64} // HepRotationY::eulerAngles()
65
66
67// From the defining code in the implementation of CLHEP (in Rotation.cc)
68// it is clear that thetaX, phiX form the polar angles in the original
69// coordinate system of the new X axis (and similarly for phiY and phiZ).
70//
71// This code is taken directly from the original CLHEP. However, there are as
72// shown opportunities for significant speed improvement.
73
74double HepRotationY::phiX() const {
75 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
76 // or ---- return 0;
77}
78
79double HepRotationY::phiY() const {
80 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
81 // or ---- return CLHEP::halfpi;
82}
83
84double HepRotationY::phiZ() const {
85 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
86 // or ---- return 0;
87}
88
89double HepRotationY::thetaX() const {
90 return safe_acos(zx());
91}
92
93double HepRotationY::thetaY() const {
94 return safe_acos(zy());
95 // or ---- return CLHEP::halfpi;
96}
97
98double HepRotationY::thetaZ() const {
99 return safe_acos(zz());
100 // or ---- return d;
101}
102
103void HepRotationY::setDelta ( double ddelta ) {
104 set(ddelta);
105}
106
108 (HepAxisAngle & rotation, Hep3Vector & boost) const {
109 boost.set(0,0,0);
110 rotation = axisAngle();
111}
112
114 (Hep3Vector & boost, HepAxisAngle & rotation) const {
115 boost.set(0,0,0);
116 rotation = axisAngle();
117}
118
120 (HepRotation & rotation, HepBoost & boost) const {
121 boost.set(0,0,0);
122 rotation = HepRotation(*this);
123}
124
126 (HepBoost & boost, HepRotation & rotation) const {
127 boost.set(0,0,0);
128 rotation = HepRotation(*this);
129}
130
131double HepRotationY::distance2( const HepRotationY & r ) const {
132 double answer = 2.0 * ( 1.0 - ( its_s * r.its_s + its_c * r.its_c ) ) ;
133 return (answer >= 0) ? answer : 0;
134}
135
136double HepRotationY::distance2( const HepRotation & r ) const {
137 double sum = xx() * r.xx() + xz() * r.xz()
138 + r.yy()
139 + zx() * r.zx() + zz() * r.zz();
140 double answer = 3.0 - sum;
141 return (answer >= 0 ) ? answer : 0;
142}
143
144double HepRotationY::distance2( const HepLorentzRotation & lt ) const {
145 HepAxisAngle a;
146 Hep3Vector b;
147 lt.decompose(b, a);
148 double bet = b.beta();
149 double bet2 = bet*bet;
150 HepRotation r(a);
151 return bet2/(1-bet2) + distance2(r);
152}
153
154double HepRotationY::distance2( const HepBoost & lt ) const {
155 return distance2( HepLorentzRotation(lt));
156}
157
158double HepRotationY::howNear( const HepRotationY & r ) const {
159 return std::sqrt(distance2(r));
160}
161double HepRotationY::howNear( const HepRotation & r ) const {
162 return std::sqrt(distance2(r));
163}
164double HepRotationY::howNear( const HepBoost & lt ) const {
165 return std::sqrt(distance2(lt));
166}
167double HepRotationY::howNear( const HepLorentzRotation & lt ) const {
168 return std::sqrt(distance2(lt));
169}
170bool HepRotationY::isNear(const HepRotationY & r,double epsilon)const{
171 return (distance2(r) <= epsilon*epsilon);
172}
173bool HepRotationY::isNear(const HepRotation & r,double epsilon)const {
174 return (distance2(r) <= epsilon*epsilon);
175}
176bool HepRotationY::isNear( const HepBoost & lt,double epsilon) const {
177 return (distance2(lt) <= epsilon*epsilon);
178}
180 double epsilon) const {
181 return (distance2(lt) <= epsilon*epsilon);
182}
183
184double HepRotationY::norm2() const {
185 return 2.0 - 2.0 * its_c;
186}
187
188std::ostream & HepRotationY::print( std::ostream & os ) const {
189 os << "\nRotation about Y (" << its_d <<
190 ") [cos d = " << its_c << " sin d = " << its_s << "]\n";
191 return os;
192}
193
194} // namespace CLHEP
G4double epsilon(G4double density, G4double temperature)
double beta() const
Definition: SpaceVectorP.cc:26
void set(double x, double y, double z)
HepBoost & set(double betaX, double betaY, double betaZ)
Definition: Boost.cc:20
void decompose(Hep3Vector &boost, HepAxisAngle &rotation) const
void setDelta(double delta)
Definition: RotationY.cc:103
static double proper(double delta)
double phiZ() const
Definition: RotationY.cc:84
double zz() const
double yz() const
double theta() const
Definition: RotationY.cc:48
double yx() const
bool isNear(const HepRotationY &r, double epsilon=Hep4RotationInterface::tolerance) const
Definition: RotationY.cc:170
double howNear(const HepRotationY &r) const
Definition: RotationY.cc:158
double zy() const
double zx() const
double xx() const
double phi() const
Definition: RotationY.cc:38
void decompose(HepAxisAngle &rotation, Hep3Vector &boost) const
Definition: RotationY.cc:108
HepRotationY & set(double delta)
Definition: RotationY.cc:31
double xz() const
HepAxisAngle axisAngle() const
double thetaY() const
Definition: RotationY.cc:93
double distance2(const HepRotationY &r) const
Definition: RotationY.cc:131
std::ostream & print(std::ostream &os) const
Definition: RotationY.cc:188
double yy() const
double phiY() const
Definition: RotationY.cc:79
double psi() const
Definition: RotationY.cc:52
double xy() const
double thetaX() const
Definition: RotationY.cc:89
double thetaZ() const
Definition: RotationY.cc:98
double phiX() const
Definition: RotationY.cc:74
double norm2() const
Definition: RotationY.cc:184
HepEulerAngles eulerAngles() const
Definition: RotationY.cc:62
double zz() const
double zx() const
double xx() const
double yy() const
double xz() const
Definition: DoubConv.h:17