Geant4  10.00.p03
RotationP.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 HepRotation class which
7 // were introduced when ZOOM PhysicsVectors was merged in, other than those
8 // involving Euler or axis/angle representations, lengthy corrections of
9 // the rotation matrix, or I/O.
10 //
11 
12 #ifdef GNUPRAGMA
13 #pragma implementation
14 #endif
15 
16 #include "CLHEP/Vector/Rotation.h"
17 
18 #include <cmath>
19 
20 
21 namespace CLHEP {
22 
23 void HepRotation::decompose(HepAxisAngle & rotation, Hep3Vector & boost)const {
24  boost.set(0,0,0);
25  rotation = axisAngle();
26 }
27 
28 void HepRotation::decompose(Hep3Vector & boost, HepAxisAngle & rotation)const {
29  boost.set(0,0,0);
30  rotation = axisAngle();
31 }
32 
33 double HepRotation::distance2( const HepRotation & r ) const {
34  double sum = rxx * r.rxx + rxy * r.rxy + rxz * r.rxz
35  + ryx * r.ryx + ryy * r.ryy + ryz * r.ryz
36  + rzx * r.rzx + rzy * r.rzy + rzz * r.rzz;
37  double answer = 3.0 - sum;
38  return (answer >= 0 ) ? answer : 0;
39 }
40 
41 double HepRotation::howNear( const HepRotation & r ) const {
42  return std::sqrt( distance2( r ) );
43 }
44 
45 bool HepRotation::isNear( const HepRotation & r,
46  double epsilon) const {
47  return distance2( r ) <= epsilon*epsilon;
48 }
49 
50 double HepRotation::norm2() const {
51  double answer = 3.0 - rxx - ryy - rzz;
52  return (answer >= 0 ) ? answer : 0;
53 }
54 
55 } // namespace CLHEP