Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotationZ.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 HepRotationZ 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
31HepRotationZ & HepRotationZ::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 HepRotationZ::phi() const {
39 return - its_d/2.0;
40} // HepRotationZ::phi()
41
42double HepRotationZ::theta() const {
43 return 0.0 ;
44} // HepRotationZ::theta()
45
46double HepRotationZ::psi() const {
47 return - its_d/2.0;
48} // HepRotationZ::psi()
49
51 return HepEulerAngles( phi(), theta(), psi() );
52} // HepRotationZ::eulerAngles()
53
54
55// From the defining code in the implementation of CLHEP (in Rotation.cc)
56// it is clear that thetaX, phiX form the polar angles in the original
57// coordinate system of the new X axis (and similarly for phiY and phiZ).
58//
59// This code is take directly from CLHEP original. However, there are as
60// shown opportunities for significant speed improvement.
61
62double HepRotationZ::phiX() const {
63 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
64 // or ---- return d;
65}
66
67double HepRotationZ::phiY() const {
68 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
69}
70
71double HepRotationZ::phiZ() const {
72 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
73 // or ---- return 0.0;
74}
75
76double HepRotationZ::thetaX() const {
77 return safe_acos(zx());
78 // or ---- return CLHEP::halfpi;
79}
80
81double HepRotationZ::thetaY() const {
82 return safe_acos(zy());
83 // or ---- return CLHEP::halfpi;
84}
85
86double HepRotationZ::thetaZ() const {
87 return safe_acos(zz());
88 // or ---- return 0.0;
89}
90
91void HepRotationZ::setDelta ( double ddelta ) {
92 set(ddelta);
93}
94
96 (HepAxisAngle & rotation, Hep3Vector & boost) const {
97 boost.set(0,0,0);
98 rotation = axisAngle();
99}
100
102 (Hep3Vector & boost, HepAxisAngle & rotation) const {
103 boost.set(0,0,0);
104 rotation = axisAngle();
105}
106
108 (HepRotation & rotation, HepBoost & boost) const {
109 boost.set(0,0,0);
110 rotation = HepRotation(*this);
111}
112
114 (HepBoost & boost, HepRotation & rotation) const {
115 boost.set(0,0,0);
116 rotation = HepRotation(*this);
117}
118
119double HepRotationZ::distance2( const HepRotationZ & r ) const {
120 double answer = 2.0 * ( 1.0 - ( its_s * r.its_s + its_c * r.its_c ) ) ;
121 return (answer >= 0) ? answer : 0;
122}
123
124double HepRotationZ::distance2( const HepRotation & r ) const {
125 double sum = xx() * r.xx() + xy() * r.xy()
126 + yx() * r.yx() + yy() * r.yy()
127 + r.zz();
128 double answer = 3.0 - sum;
129 return (answer >= 0 ) ? answer : 0;
130}
131
132double HepRotationZ::distance2( const HepLorentzRotation & lt ) const {
133 HepAxisAngle a;
134 Hep3Vector b;
135 lt.decompose(b, a);
136 double bet = b.beta();
137 double bet2 = bet*bet;
138 HepRotation r(a);
139 return bet2/(1-bet2) + distance2(r);
140}
141
142double HepRotationZ::distance2( const HepBoost & lt ) const {
143 return distance2( HepLorentzRotation(lt));
144}
145
146double HepRotationZ::howNear( const HepRotationZ & r ) const {
147 return std::sqrt(distance2(r));
148}
149double HepRotationZ::howNear( const HepRotation & r ) const {
150 return std::sqrt(distance2(r));
151}
152double HepRotationZ::howNear( const HepBoost & lt ) const {
153 return std::sqrt(distance2(lt));
154}
155double HepRotationZ::howNear( const HepLorentzRotation & lt ) const {
156 return std::sqrt(distance2(lt));
157}
158bool HepRotationZ::isNear(const HepRotationZ & r,double epsilon)const {
159 return (distance2(r) <= epsilon*epsilon);
160}
161bool HepRotationZ::isNear(const HepRotation & r,double epsilon)const {
162 return (distance2(r) <= epsilon*epsilon);
163}
164bool HepRotationZ::isNear( const HepBoost & lt,double epsilon) const {
165 return (distance2(lt) <= epsilon*epsilon);
166}
168 double epsilon) const {
169 return (distance2(lt) <= epsilon*epsilon);
170}
171
172double HepRotationZ::norm2() const {
173 return 2.0 - 2.0 * its_c;
174}
175
176std::ostream & HepRotationZ::print( std::ostream & os ) const {
177 os << "\nRotation about Z (" << its_d <<
178 ") [cos d = " << its_c << " sin d = " << its_s << "]\n";
179 return os;
180}
181
182} // namespace CLHEP
183
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
double xy() const
double distance2(const HepRotationZ &r) const
Definition: RotationZ.cc:119
double yz() const
double psi() const
Definition: RotationZ.cc:46
double norm2() const
Definition: RotationZ.cc:172
HepAxisAngle axisAngle() const
double phi() const
Definition: RotationZ.cc:38
double xz() const
double thetaX() const
Definition: RotationZ.cc:76
bool isNear(const HepRotationZ &r, double epsilon=Hep4RotationInterface::tolerance) const
Definition: RotationZ.cc:158
double zz() const
double thetaZ() const
Definition: RotationZ.cc:86
double xx() const
double zx() const
double phiX() const
Definition: RotationZ.cc:62
static double proper(double delta)
double yy() const
HepRotationZ & set(double delta)
Definition: RotationZ.cc:31
void setDelta(double delta)
Definition: RotationZ.cc:91
double phiZ() const
Definition: RotationZ.cc:71
void decompose(HepAxisAngle &rotation, Hep3Vector &boost) const
Definition: RotationZ.cc:96
double phiY() const
Definition: RotationZ.cc:67
HepEulerAngles eulerAngles() const
Definition: RotationZ.cc:50
double thetaY() const
Definition: RotationZ.cc:81
std::ostream & print(std::ostream &os) const
Definition: RotationZ.cc:176
double yx() const
double theta() const
Definition: RotationZ.cc:42
double zy() const
double howNear(const HepRotationZ &r) const
Definition: RotationZ.cc:146
double zz() const
double yx() const
double xx() const
double yy() const
double xy() const
Definition: DoubConv.h:17