00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifdef GNUPRAGMA
00012 #pragma implementation
00013 #endif
00014
00015 #include "CLHEP/Vector/ThreeVector.h"
00016
00017 #include <cmath>
00018
00019 namespace CLHEP {
00020
00021
00022
00023
00024
00025
00026
00027
00028 double Hep3Vector::polarAngle (const Hep3Vector & v2) const {
00029 return std::fabs(v2.getTheta() - getTheta());
00030 }
00031
00032 double Hep3Vector::polarAngle (const Hep3Vector & v2,
00033 const Hep3Vector & ref) const {
00034 return std::fabs( v2.angle(ref) - angle(ref) );
00035 }
00036
00037
00038
00039
00040 double Hep3Vector::azimAngle (const Hep3Vector & v2,
00041 const Hep3Vector & ref) const {
00042
00043 Hep3Vector vperp ( perpPart(ref) );
00044 if ( vperp.mag2() == 0 ) {
00045 std::cerr << "Hep3Vector::azimAngle() - "
00046 << "Cannot find azimuthal angle with reference direction parallel to "
00047 << "vector 1 -- will return zero" << std::endl;
00048 return 0;
00049 }
00050
00051 Hep3Vector v2perp ( v2.perpPart(ref) );
00052 if ( v2perp.mag2() == 0 ) {
00053 std::cerr << "Hep3Vector::azimAngle() - "
00054 << "Cannot find azimuthal angle with reference direction parallel to "
00055 << "vector 2 -- will return zero" << std::endl;
00056 return 0;
00057 }
00058
00059 double ang = vperp.angle(v2perp);
00060
00061
00062
00063
00064 if ( dot(v2.cross(ref)) >= 0 ) {
00065 return ang;
00066 } else {
00067 return -ang;
00068 }
00069
00070
00071
00072
00073
00074 }
00075
00076 }