Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
AxisAngle.cc
이 파일의 문서화 페이지로 가기
1 // ----------------------------------------------------------------------
2 //
3 // AxisAngle.cc
4 //
5 // History:
6 // 23-Jan-1998 WEB Initial draft
7 // 13-Mar-1998 WEB Corrected ZMpvAxisAngleRep
8 // 15-Jun-1998 WEB Added namespace support
9 // 26-Jul-2000 MF CLHEP version
10 // 12-Apr-2001 MF NaN-proofing
11 //
12 // ----------------------------------------------------------------------
13 
14 #include "CLHEP/Vector/AxisAngle.h"
15 
16 namespace CLHEP {
17 
19 
20 static void ZMpvAxisAngleRep( const HepAxisAngle & aa, double array[] ) {
21 
22  double sinDelta = std::sin( aa.delta() );
23  double cosDelta = std::cos( aa.delta() );
24  double oneMinusCosDelta = 1.0 - cosDelta;
25 
26  double uX = aa.getAxis().getX();
27  double uY = aa.getAxis().getY();
28  double uZ = aa.getAxis().getZ();
29 
30  array[0] = oneMinusCosDelta * uX * uX + cosDelta;
31  array[1] = oneMinusCosDelta * uX * uY - sinDelta * uZ;
32  array[2] = oneMinusCosDelta * uX * uZ + sinDelta * uY;
33 
34  array[3] = oneMinusCosDelta * uY * uX + sinDelta * uZ;
35  array[4] = oneMinusCosDelta * uY * uY + cosDelta;
36  array[5] = oneMinusCosDelta * uY * uZ - sinDelta * uX;
37 
38  array[6] = oneMinusCosDelta * uZ * uX - sinDelta * uY;
39  array[7] = oneMinusCosDelta * uZ * uY + sinDelta * uX;
40  array[8] = oneMinusCosDelta * uZ * uZ + cosDelta;
41 
42 } // ZMpvAxisAngleRep
43 
44 
45 double HepAxisAngle::distance( const AA & aa ) const {
46 
47  double thisRep[9];
48  double aaRep[9];
49 
50  ZMpvAxisAngleRep( *this, thisRep );
51  ZMpvAxisAngleRep( aa, aaRep );
52 
53  double sum = 0.0;
54  for ( int i = 0; i < 9; i++ ) {
55  sum += thisRep[i] * aaRep[i];
56  }
57 
58  double d = 3.0 - sum; // NaN-proofing:
59  return (d >= 0) ? d : 0; // std::sqrt(distance) is used in howNear()
60 
61 } // HepAxisAngle::distance()
62 
63 
64 bool HepAxisAngle::isNear( const AA & aa, Scalar epsilon ) const {
65 
66  return distance( aa ) <= epsilon * epsilon;
67 
68 } // HepAxisAngle::isNear()
69 
70 
71 double HepAxisAngle::howNear( const AA & aa ) const {
72 
73  return std::sqrt( distance( aa ) );
74 
75 } // HepAxisAngle::howNear()
76 
77 
78 //-********************
79 //
80 // Global methods
81 //
82 //-********************
83 
84 
85 std::ostream & operator<<(std::ostream & os, const HepAxisAngle & aa) {
86  os << '(' << aa.axis() << ", " << aa.delta() << ')';
87  return os;
88 } // operator<<()
89 
90 
91 void ZMinputAxisAngle ( std::istream & is,
92  double & x, double & y, double & z,
93  double & delta );
94 
95 std::istream & operator>>(std::istream & is, HepAxisAngle & aa) {
96  Hep3Vector axis;
97  double delta;
98  double x,y,z;
99  ZMinputAxisAngle ( is, x, y, z, delta );
100  axis.set(x,y,z);
101  aa.set ( axis, delta );
102  return is;
103 } // operator>>()
104 
105 } // namespace CLHEP
Float_t x
Definition: compare.C:6
void set(double x, double y, double z)
std::ostream & operator<<(std::ostream &os, const HepRandom &dist)
Definition: Random.cc:216
double delta() const
AA & set(const Hep3Vector axis, Scalar delta)
double getZ() const
Float_t y
Definition: compare.C:6
Double_t z
double howNear(const AA &aa) const
Definition: AxisAngle.cc:71
std::istream & operator>>(std::istream &is, HepRandom &dist)
Definition: Random.cc:220
static Scalar tolerance
Definition: AxisAngle.h:43
bool isNear(const AA &aa, Scalar epsilon=tolerance) const
Definition: AxisAngle.cc:64
double getX() const
Float_t d
static void ZMpvAxisAngleRep(const HepAxisAngle &aa, double array[])
Definition: AxisAngle.cc:20
double getY() const
double epsilon(double density, double temperature)
double distance(const HepAxisAngle &aa) const
Definition: AxisAngle.cc:45
Hep3Vector getAxis() const
void ZMinputAxisAngle(std::istream &is, double &x, double &y, double &z, double &delta)
Definition: ZMinput.cc:156
Hep3Vector axis() const