CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

AxisAngle.cc
Go to the documentation of this file.
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/defs.h"
15 #include "CLHEP/Vector/AxisAngle.h"
16 
17 namespace CLHEP {
18 
20 
21 static void ZMpvAxisAngleRep( const HepAxisAngle & aa, double array[] ) {
22 
23  register double sinDelta = std::sin( aa.delta() );
24  register double cosDelta = std::cos( aa.delta() );
25  register double oneMinusCosDelta = 1.0 - cosDelta;
26 
27  register double uX = aa.getAxis().getX();
28  register double uY = aa.getAxis().getY();
29  register double uZ = aa.getAxis().getZ();
30 
31  array[0] = oneMinusCosDelta * uX * uX + cosDelta;
32  array[1] = oneMinusCosDelta * uX * uY - sinDelta * uZ;
33  array[2] = oneMinusCosDelta * uX * uZ + sinDelta * uY;
34 
35  array[3] = oneMinusCosDelta * uY * uX + sinDelta * uZ;
36  array[4] = oneMinusCosDelta * uY * uY + cosDelta;
37  array[5] = oneMinusCosDelta * uY * uZ - sinDelta * uX;
38 
39  array[6] = oneMinusCosDelta * uZ * uX - sinDelta * uY;
40  array[7] = oneMinusCosDelta * uZ * uY + sinDelta * uX;
41  array[8] = oneMinusCosDelta * uZ * uZ + cosDelta;
42 
43 } // ZMpvAxisAngleRep
44 
45 
46 double HepAxisAngle::distance( const AA & aa ) const {
47 
48  double thisRep[9];
49  double aaRep[9];
50 
51  ZMpvAxisAngleRep( *this, thisRep );
52  ZMpvAxisAngleRep( aa, aaRep );
53 
54  double sum = 0.0;
55  for ( int i = 0; i < 9; i++ ) {
56  sum += thisRep[i] * aaRep[i];
57  }
58 
59  double d = 3.0 - sum; // NaN-proofing:
60  return (d >= 0) ? d : 0; // std::sqrt(distance) is used in howNear()
61 
62 } // HepAxisAngle::distance()
63 
64 
65 bool HepAxisAngle::isNear( const AA & aa, Scalar epsilon ) const {
66 
67  return distance( aa ) <= epsilon * epsilon;
68 
69 } // HepAxisAngle::isNear()
70 
71 
72 double HepAxisAngle::howNear( const AA & aa ) const {
73 
74  return std::sqrt( distance( aa ) );
75 
76 } // HepAxisAngle::howNear()
77 
78 
79 //-********************
80 //
81 // Global methods
82 //
83 //-********************
84 
85 
86 std::ostream & operator<<(std::ostream & os, const HepAxisAngle & aa) {
87  os << '(' << aa.axis() << ", " << aa.delta() << ')';
88  return os;
89 } // operator<<()
90 
91 
92 void ZMinputAxisAngle ( std::istream & is,
93  double & x, double & y, double & z,
94  double & delta );
95 
96 std::istream & operator>>(std::istream & is, HepAxisAngle & aa) {
98  double delta;
99  double x,y,z;
100  ZMinputAxisAngle ( is, x, y, z, delta );
101  axis.set(x,y,z);
102  aa.set ( axis, delta );
103  return is;
104 } // operator>>()
105 
106 } // namespace CLHEP
delta
HepRotation delta() setPhi()
CLHEP::HepAxisAngle
Definition: Geometry/CLHEP/Vector/AxisAngle.h:37
CLHEP::HepAxisAngle::axis
Hep3Vector axis() const
CLHEP::HepAxisAngle::tolerance
static Scalar tolerance
Definition: Geometry/CLHEP/Vector/AxisAngle.h:44
CLHEP::HepAxisAngle::isNear
bool isNear(const AA &aa, Scalar epsilon=tolerance) const
Definition: AxisAngle.cc:65
CLHEP::HepLorentzVector::set
void set(double x, double y, double z, double t)
CLHEP::ZMinputAxisAngle
void ZMinputAxisAngle(std::istream &is, double &x, double &y, double &z, double &delta)
Definition: ZMinput.cc:152
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::HepAxisAngle::howNear
double howNear(const AA &aa) const
Definition: AxisAngle.cc:72
axis
We have the boost methods returning HepLorentzVector &rather than so things can be chained we feel the boost methods along an axis
Definition: minorMergeIssues.doc:155
CLHEP::HepAxisAngle::set
AA & set(const Hep3Vector axis, Scalar delta)
CLHEP::HepAxisAngle::distance
double distance(const HepAxisAngle &aa) const
Definition: AxisAngle.cc:46
CLHEP
Definition: ClhepVersion.h:13
CLHEP::Hep3Vector::ToleranceTicks
@ ToleranceTicks
Definition: Geometry/CLHEP/Vector/ThreeVector.h:299
CLHEP::Hep3Vector
Definition: Geometry/CLHEP/Vector/ThreeVector.h:41
CLHEP::operator>>
std::istream & operator>>(std::istream &is, HepAxisAngle &aa)
Definition: AxisAngle.cc:96
CLHEP::HepAxisAngle::delta
double delta() const
i
long i
Definition: JamesRandomSeeding.txt:27
CLHEP::HepAxisAngle::Scalar
double Scalar
Definition: Geometry/CLHEP/Vector/AxisAngle.h:40
CLHEP::operator<<
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
Definition: AxisAngle.cc:86
x
any side effects of that construction would occur twice The semantics of throw x
Definition: whyZMthrowRethrows.txt:37