Geant4  v4-10.4-release
RotationX.cc
이 파일의 문서화 페이지로 가기
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 HepRotationX class which
7 // were introduced when ZOOM PhysicsVectors was merged in.
8 //
9
10 #ifdef GNUPRAGMA
11 #pragma implementation
12 #endif
13
14 #include "CLHEP/Vector/RotationX.h"
15 #include "CLHEP/Vector/AxisAngle.h"
19
20 #include <cmath>
21 #include <stdlib.h>
22 #include <iostream>
23
24 namespace CLHEP {
25
26 static inline double safe_acos (double x) {
27  if (std::abs(x) <= 1.0) return std::acos(x);
28  return ( (x>0) ? 0 : CLHEP::pi );
29 }
30
31 HepRotationX::HepRotationX(double ddelta) :
32  its_d(proper(ddelta)), its_s(std::sin(ddelta)), its_c(std::cos(ddelta))
33 {}
34
35 HepRotationX & HepRotationX::set ( double ddelta ) {
36  its_d = proper(ddelta);
37  its_s = std::sin(its_d);
38  its_c = std::cos(its_d);
39  return *this;
40 }
41
42 double HepRotationX::phi() const {
43  if ( (its_d > 0) && (its_d < CLHEP::pi) ) {
44  return CLHEP::pi;
45  } else {
46  return 0.0;
47  }
48 } // HepRotationX::phi()
49
50 double HepRotationX::theta() const {
51  return std::fabs( its_d );
52 } // HepRotationX::theta()
53
54 double HepRotationX::psi() const {
55  if ( (its_d > 0) && (its_d < CLHEP::pi) ) {
56  return CLHEP::pi;
57  } else {
58  return 0.0;
59  }
60 } // HepRotationX::psi()
61
63  return HepEulerAngles( phi(), theta(), psi() );
64 } // HepRotationX::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
74 double HepRotationX::phiX() const {
75  return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
76  // or ---- return 0;
77 }
78
79 double HepRotationX::phiY() const {
80  return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
81  // or ---- return (yy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
82 }
83
84 double HepRotationX::phiZ() const {
85  return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
86  // or ---- return (yz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
87 }
88
89 double HepRotationX::thetaX() const {
90  return safe_acos(zx());
91  // or ---- return CLHEP::halfpi;
92 }
93
94 double HepRotationX::thetaY() const {
95  return safe_acos(zy());
96 }
97
98 double HepRotationX::thetaZ() const {
99  return safe_acos(zz());
100  // or ---- return d;
101 }
102
103 void HepRotationX::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
131 double HepRotationX::distance2( const HepRotationX & r ) const {
132  double answer = 2.0 * ( 1.0 - ( its_s * r.its_s + its_c * r.its_c ) ) ;
134 }
135
136 double HepRotationX::distance2( const HepRotation & r ) const {
137  double sum = r.xx() +
138  yy() * r.yy() + yz() * r.yz()
139  + zy() * r.zy() + zz() * r.zz();
140  double answer = 3.0 - sum;
142 }
143
144 double HepRotationX::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
154 double HepRotationX::distance2( const HepBoost & lt ) const {
155  return distance2( HepLorentzRotation(lt));
156 }
157
158 double HepRotationX::howNear( const HepRotationX & r ) const {
159  return std::sqrt(distance2(r));
160 }
161 double HepRotationX::howNear( const HepRotation & r ) const {
162  return std::sqrt(distance2(r));
163 }
164 double HepRotationX::howNear( const HepBoost & b ) const {
165  return std::sqrt(distance2(b));
166 }
167 double HepRotationX::howNear( const HepLorentzRotation & lt ) const {
168  return std::sqrt(distance2(lt));
169 }
170 bool HepRotationX::isNear(const HepRotationX & r,double epsilon)const{
171  return (distance2(r) <= epsilon*epsilon);
172 }
173 bool HepRotationX::isNear(const HepRotation & r,double epsilon) const{
174  return (distance2(r) <= epsilon*epsilon);
175 }
176 bool HepRotationX::isNear( const HepBoost & lt,double epsilon) const {
177  return (distance2(lt) <= epsilon*epsilon);
178 }
179
181  double epsilon ) const {
182  return (distance2(lt) <= epsilon*epsilon);
183 }
184
185 double HepRotationX::norm2() const {
186  return 2.0 - 2.0 * its_c;
187 }
188
189 std::ostream & HepRotationX::print( std::ostream & os ) const {
190  os << "\nRotation about X (" << its_d <<
191  ") [cos d = " << its_c << " sin d = " << its_s << "]\n";
192  return os;
193 }
194
195 } // namespace CLHEP
196
Float_t x
Definition: compare.C:6
void set(double x, double y, double z)
double norm2() const
Definition: RotationX.cc:185
double thetaZ() const
Definition: RotationX.cc:98
double zy() const
HepRotationX & set(double delta)
Definition: RotationX.cc:35
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
double distance2(const HepRotationX &r) const
Definition: RotationX.cc:131
double phi() const
Definition: RotationX.cc:42
double xx() const
double zz() const
double phiZ() const
Definition: RotationX.cc:84
double thetaY() const
Definition: RotationX.cc:94
HepBoost & set(double betaX, double betaY, double betaZ)
Definition: Boost.cc:21
double yz() const
double yz() const
double yx() const
double xz() const
HepEulerAngles eulerAngles() const
Definition: RotationX.cc:62
void setDelta(double delta)
Definition: RotationX.cc:103
double xx() const
double yy() const
static double safe_acos(double x)
Definition: Rotation.cc:23
double phiX() const
Definition: RotationX.cc:74
void decompose(HepAxisAngle &rotation, Hep3Vector &boost) const
Definition: RotationX.cc:108
double phiY() const
Definition: RotationX.cc:79
double xy() const
double zz() const
double epsilon(double density, double temperature)
double zy() const
double thetaX() const
Definition: RotationX.cc:89
double howNear(const HepRotationX &r) const
Definition: RotationX.cc:158
double yy() const
void decompose(Hep3Vector &boost, HepAxisAngle &rotation) const
static double proper(double delta)
double psi() const
Definition: RotationX.cc:54
double beta() const
Definition: SpaceVectorP.cc:30
double theta() const
Definition: RotationX.cc:50
std::ostream & print(std::ostream &os) const
Definition: RotationX.cc:189
double zx() const
static constexpr double pi
Definition: SystemOfUnits.h:54
bool isNear(const HepRotationX &r, double epsilon=Hep4RotationInterface::tolerance) const
Definition: RotationX.cc:170