Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
EulerAngles.cc
이 파일의 문서화 페이지로 가기
1 // ----------------------------------------------------------------------
2 //
3 // EulerAngles.cc
4 //
5 // Methods for classes, and instances of globals, declared in EulerAngles.h
6 //
7 // History:
8 //
9 // 04-Dec-1997 MF Stub with just PI
10 // 12-Jan-1998 WEB PI now found in ZMutility; used ZMutility headers
11 // where available
12 // 16-Mar-1998 WEB Corrected ZMpvEulerAnglesRep
13 // 15-Jun-1998 WEB Added namespace support
14 // 26-Jul-2000 MF CLHEP version
15 // 12-Apr-2001 MF NaN-proofing
16 // 19-Nov-2001 MF Correction to ZMpvEulerAnglesRep, which was affecting
17 // .isNear(). array[3] had been incorrect.
18 // Note - the correct form was used in all other places
19 // including Rotation.set(phi, theta, psi).
20 //
21 // ----------------------------------------------------------------------
22 
23 
25 
27 
28 #include <iostream>
29 
30 namespace CLHEP {
31 
32 //-*************
33 // static consts
34 //-*************
35 
37 
38 //-*******************
39 // measure of distance
40 //-*******************
41 
42 
43 static void ZMpvEulerAnglesRep ( const HepEulerAngles & ex, double array[] ) {
44 
45  double sinPhi = std::sin( ex.phi() ) , cosPhi = std::cos( ex.phi() );
46  double sinTheta = std::sin( ex.theta() ), cosTheta = std::cos( ex.theta() );
47  double sinPsi = std::sin( ex.psi() ) , cosPsi = std::cos( ex.psi() );
48 
49  array[0] = cosPsi * cosPhi - sinPsi * cosTheta * sinPhi;
50  array[1] = cosPsi * sinPhi + sinPsi * cosTheta * cosPhi;
51  array[2] = sinPsi * sinTheta;
52 
53  array[3] = - sinPsi * cosPhi - cosPsi * cosTheta * sinPhi;
54  array[4] = - sinPsi * sinPhi + cosPsi * cosTheta * cosPhi;
55  array[5] = cosPsi * sinTheta;
56 
57  array[6] = sinTheta * sinPhi;
58  array[7] = - sinTheta * cosPhi;
59  array[8] = cosTheta;
60 
61 } // ZMpvEulerAnglesRep
62 
63 
64 double HepEulerAngles::distance( const EA & ex ) const {
65 
66  double thisRep[9];
67  double exRep[9];
68 
69  ZMpvEulerAnglesRep ( *this, thisRep );
70  ZMpvEulerAnglesRep ( ex, exRep );
71 
72  double sum = 0.0;
73  for (int i = 0; i < 9; i++) {
74  sum += thisRep[i] * exRep[i];
75  }
76 
77  double d = 3.0 - sum; // NaN-proofing:
78  return (d >= 0) ? d : 0; // sqrt(distance) is used in howNear()
79 
80 } // HepEulerAngles::distance()
81 
82 
83 bool HepEulerAngles::isNear( const EA & ex, double epsilon ) const {
84 
85  return distance( ex ) <= epsilon*epsilon ;
86 
87 } // HepEulerAngles::isNear()
88 
89 
90 double HepEulerAngles::howNear( const EA & ex ) const {
91 
92  return std::sqrt( distance( ex ) );
93 
94 } // HepEulerAngles::howNear()
95 
96 //-**************
97 // Global Methods
98 //-**************
99 
100 std::ostream & operator<<(std::ostream & os, const HepEulerAngles & ea)
101 {
102  os << "(" << ea.phi() << ", " << ea.theta() << ", " << ea.psi() << ")";
103  return os;
104 } // operator<<()
105 
106 void ZMinput3doubles ( std::istream & is, const char * type,
107  double & x, double & y, double & z );
108 
109 std::istream & operator>>(std::istream & is, HepEulerAngles & ea) {
110  double thePhi;
111  double theTheta;
112  double thePsi;
113  ZMinput3doubles ( is, "HepEulerAngle", thePhi , theTheta , thePsi );
114  ea.set ( thePhi , theTheta , thePsi );
115  return is;
116 } // operator>>()
117 
118 } // namespace CLHEP
119 
120 
Float_t x
Definition: compare.C:6
double distance(const HepEulerAngles &ex) const
Definition: EulerAngles.cc:64
void ZMinput3doubles(std::istream &is, const char *type, double &x, double &y, double &z)
Definition: ZMinput.cc:42
double psi() const
std::ostream & operator<<(std::ostream &os, const HepRandom &dist)
Definition: Random.cc:216
Float_t y
Definition: compare.C:6
Double_t z
static void ZMpvEulerAnglesRep(const HepEulerAngles &ex, double array[])
Definition: EulerAngles.cc:43
EA & set(double phi, double theta, double psi)
bool isNear(const EA &ea, double epsilon=tolerance) const
Definition: EulerAngles.cc:83
std::istream & operator>>(std::istream &is, HepRandom &dist)
Definition: Random.cc:220
double phi() const
static double tolerance
Definition: EulerAngles.h:43
Float_t d
double theta() const
double epsilon(double density, double temperature)
double howNear(const EA &ea) const
Definition: EulerAngles.cc:90