CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
RotationZ.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 HepRotationZ class which
7// were introduced when ZOOM PhysicsVectors was merged in.
8//
9
10#include "CLHEP/Vector/defs.h"
11#include "CLHEP/Vector/RotationZ.h"
12#include "CLHEP/Vector/AxisAngle.h"
13#include "CLHEP/Vector/EulerAngles.h"
14#include "CLHEP/Vector/LorentzRotation.h"
15#include "CLHEP/Units/PhysicalConstants.h"
16
17#include <cmath>
18#include <stdlib.h>
19#include <iostream>
20
21namespace CLHEP {
22
23static inline double safe_acos (double x) {
24 if (std::abs(x) <= 1.0) return std::acos(x);
25 return ( (x>0) ? 0 : CLHEP::pi );
26}
27
29 its_d(proper(dddelta)), its_s(std::sin(dddelta)), its_c(std::cos(dddelta))
30{}
31
32HepRotationZ & HepRotationZ::set ( double dddelta ) {
33 its_d = proper(dddelta);
34 its_s = std::sin(its_d);
35 its_c = std::cos(its_d);
36 return *this;
37}
38
39double HepRotationZ::phi() const {
40 return - its_d/2.0;
41} // HepRotationZ::phi()
42
43double HepRotationZ::theta() const {
44 return 0.0 ;
45} // HepRotationZ::theta()
46
47double HepRotationZ::psi() const {
48 return - its_d/2.0;
49} // HepRotationZ::psi()
50
52 return HepEulerAngles( phi(), theta(), psi() );
53} // HepRotationZ::eulerAngles()
54
55
56// From the defining code in the implementation of CLHEP (in Rotation.cc)
57// it is clear that thetaX, phiX form the polar angles in the original
58// coordinate system of the new X axis (and similarly for phiY and phiZ).
59//
60// This code is take directly from CLHEP original. However, there are as
61// shown opportunities for significant speed improvement.
62
63double HepRotationZ::phiX() const {
64 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
65 // or ---- return d;
66}
67
68double HepRotationZ::phiY() const {
69 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
70}
71
72double HepRotationZ::phiZ() const {
73 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
74 // or ---- return 0.0;
75}
76
77double HepRotationZ::thetaX() const {
78 return safe_acos(zx());
79 // or ---- return CLHEP::halfpi;
80}
81
82double HepRotationZ::thetaY() const {
83 return safe_acos(zy());
84 // or ---- return CLHEP::halfpi;
85}
86
87double HepRotationZ::thetaZ() const {
88 return safe_acos(zz());
89 // or ---- return 0.0;
90}
91
92void HepRotationZ::setDelta ( double ddelta ) {
93 set(ddelta);
94}
95
97 (HepAxisAngle & rotation, Hep3Vector & boost) const {
98 boost.set(0,0,0);
99 rotation = axisAngle();
100}
101
103 (Hep3Vector & boost, HepAxisAngle & rotation) const {
104 boost.set(0,0,0);
105 rotation = axisAngle();
106}
107
109 (HepRotation & rotation, HepBoost & boost) const {
110 boost.set(0,0,0);
111 rotation = HepRotation(*this);
112}
113
115 (HepBoost & boost, HepRotation & rotation) const {
116 boost.set(0,0,0);
117 rotation = HepRotation(*this);
118}
119
120double HepRotationZ::distance2( const HepRotationZ & r ) const {
121 double answer = 2.0 * ( 1.0 - ( its_s * r.its_s + its_c * r.its_c ) ) ;
122 return (answer >= 0) ? answer : 0;
123}
124
125double HepRotationZ::distance2( const HepRotation & r ) const {
126 double sum = xx() * r.xx() + xy() * r.xy()
127 + yx() * r.yx() + yy() * r.yy()
128 + r.zz();
129 double answer = 3.0 - sum;
130 return (answer >= 0 ) ? answer : 0;
131}
132
133double HepRotationZ::distance2( const HepLorentzRotation & lt ) const {
134 HepAxisAngle a;
135 Hep3Vector b;
136 lt.decompose(b, a);
137 double bet = b.beta();
138 double bet2 = bet*bet;
139 HepRotation r(a);
140 return bet2/(1-bet2) + distance2(r);
141}
142
143double HepRotationZ::distance2( const HepBoost & lt ) const {
144 return distance2( HepLorentzRotation(lt));
145}
146
147double HepRotationZ::howNear( const HepRotationZ & r ) const {
148 return std::sqrt(distance2(r));
149}
150double HepRotationZ::howNear( const HepRotation & r ) const {
151 return std::sqrt(distance2(r));
152}
153double HepRotationZ::howNear( const HepBoost & lt ) const {
154 return std::sqrt(distance2(lt));
155}
156double HepRotationZ::howNear( const HepLorentzRotation & lt ) const {
157 return std::sqrt(distance2(lt));
158}
159bool HepRotationZ::isNear(const HepRotationZ & r,double epsilon)const {
160 return (distance2(r) <= epsilon*epsilon);
161}
162bool HepRotationZ::isNear(const HepRotation & r,double epsilon)const {
163 return (distance2(r) <= epsilon*epsilon);
164}
165bool HepRotationZ::isNear( const HepBoost & lt,double epsilon) const {
166 return (distance2(lt) <= epsilon*epsilon);
167}
169 double epsilon) const {
170 return (distance2(lt) <= epsilon*epsilon);
171}
172
173double HepRotationZ::norm2() const {
174 return 2.0 - 2.0 * its_c;
175}
176
177std::ostream & HepRotationZ::print( std::ostream & os ) const {
178 os << "\nRotation about Z (" << its_d <<
179 ") [cos d = " << its_c << " sin d = " << its_s << "]\n";
180 return os;
181}
182
183} // namespace CLHEP
184
double beta() const
Definition: SpaceVectorP.cc:28
void set(double x, double y, double z)
HepBoost & set(double betaX, double betaY, double betaZ)
Definition: Boost.cc:22
void decompose(Hep3Vector &boost, HepAxisAngle &rotation) const
double xy() const
double distance2(const HepRotationZ &r) const
Definition: RotationZ.cc:120
double yz() const
double psi() const
Definition: RotationZ.cc:47
double norm2() const
Definition: RotationZ.cc:173
HepAxisAngle axisAngle() const
double phi() const
Definition: RotationZ.cc:39
double xz() const
double thetaX() const
Definition: RotationZ.cc:77
bool isNear(const HepRotationZ &r, double epsilon=Hep4RotationInterface::tolerance) const
Definition: RotationZ.cc:159
double zz() const
double thetaZ() const
Definition: RotationZ.cc:87
double xx() const
double zx() const
double phiX() const
Definition: RotationZ.cc:63
static double proper(double delta)
double yy() const
HepRotationZ & set(double delta)
Definition: RotationZ.cc:32
void setDelta(double delta)
Definition: RotationZ.cc:92
double phiZ() const
Definition: RotationZ.cc:72
void decompose(HepAxisAngle &rotation, Hep3Vector &boost) const
Definition: RotationZ.cc:97
double phiY() const
Definition: RotationZ.cc:68
HepEulerAngles eulerAngles() const
Definition: RotationZ.cc:51
double thetaY() const
Definition: RotationZ.cc:82
std::ostream & print(std::ostream &os) const
Definition: RotationZ.cc:177
double yx() const
double theta() const
Definition: RotationZ.cc:43
double zy() const
double howNear(const HepRotationZ &r) const
Definition: RotationZ.cc:147
double zz() const
double yx() const
double xx() const
double yy() const
double xy() const