11 #pragma implementation
14 #include "CLHEP/Vector/RotationZ.h"
15 #include "CLHEP/Vector/AxisAngle.h"
16 #include "CLHEP/Vector/EulerAngles.h"
17 #include "CLHEP/Vector/LorentzRotation.h"
18 #include "CLHEP/Units/PhysicalConstants.h"
27 if (std::abs(x) <= 1.0)
return std::acos(x);
31 HepRotationZ::HepRotationZ(
double ddelta) :
32 its_d(proper(ddelta)), its_s(
std::sin(ddelta)), its_c(
std::cos(ddelta))
35 HepRotationZ & HepRotationZ::set (
double ddelta ) {
36 its_d = proper(ddelta);
37 its_s = std::sin(its_d);
38 its_c = std::cos(its_d);
42 double HepRotationZ::phi()
const {
46 double HepRotationZ::theta()
const {
50 double HepRotationZ::psi()
const {
54 HepEulerAngles HepRotationZ::eulerAngles()
const {
55 return HepEulerAngles( phi(), theta(), psi() );
66 double HepRotationZ::phiX()
const {
67 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
71 double HepRotationZ::phiY()
const {
72 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
75 double HepRotationZ::phiZ()
const {
76 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
80 double HepRotationZ::thetaX()
const {
85 double HepRotationZ::thetaY()
const {
90 double HepRotationZ::thetaZ()
const {
95 void HepRotationZ::setDelta (
double ddelta ) {
99 void HepRotationZ::decompose
100 (HepAxisAngle & rotation, Hep3Vector & boost)
const {
102 rotation = axisAngle();
105 void HepRotationZ::decompose
106 (Hep3Vector & boost, HepAxisAngle & rotation)
const {
108 rotation = axisAngle();
111 void HepRotationZ::decompose
112 (HepRotation & rotation, HepBoost & boost)
const {
114 rotation = HepRotation(*
this);
117 void HepRotationZ::decompose
118 (HepBoost & boost, HepRotation & rotation)
const {
120 rotation = HepRotation(*
this);
123 double HepRotationZ::distance2(
const HepRotationZ & r )
const {
124 double answer = 2.0 * ( 1.0 - ( its_s * r.its_s + its_c * r.its_c ) ) ;
125 return (answer >= 0) ? answer : 0;
128 double HepRotationZ::distance2(
const HepRotation & r )
const {
129 double sum = xx() * r.xx() + xy() * r.xy()
130 + yx() * r.yx() + yy() * r.yy()
132 double answer = 3.0 - sum;
133 return (answer >= 0 ) ? answer : 0;
136 double HepRotationZ::distance2(
const HepLorentzRotation & lt )
const {
140 double bet = b.beta();
141 double bet2 = bet*bet;
143 return bet2/(1-bet2) + distance2(r);
146 double HepRotationZ::distance2(
const HepBoost & lt )
const {
147 return distance2( HepLorentzRotation(lt));
150 double HepRotationZ::howNear(
const HepRotationZ & r )
const {
151 return std::sqrt(distance2(r));
153 double HepRotationZ::howNear(
const HepRotation & r )
const {
154 return std::sqrt(distance2(r));
156 double HepRotationZ::howNear(
const HepBoost & lt )
const {
157 return std::sqrt(distance2(lt));
159 double HepRotationZ::howNear(
const HepLorentzRotation & lt )
const {
160 return std::sqrt(distance2(lt));
162 bool HepRotationZ::isNear(
const HepRotationZ & r,
double epsilon)
const {
163 return (distance2(r) <= epsilon*epsilon);
165 bool HepRotationZ::isNear(
const HepRotation & r,
double epsilon)
const {
166 return (distance2(r) <= epsilon*epsilon);
168 bool HepRotationZ::isNear(
const HepBoost & lt,
double epsilon)
const {
169 return (distance2(lt) <= epsilon*epsilon);
171 bool HepRotationZ::isNear(
const HepLorentzRotation & lt,
172 double epsilon)
const {
173 return (distance2(lt) <= epsilon*epsilon);
176 double HepRotationZ::norm2()
const {
177 return 2.0 - 2.0 * its_c;
181 os <<
"\nRotation about Z (" << its_d <<
182 ") [cos d = " << its_c <<
" sin d = " << its_s <<
"]\n";
static double safe_acos(double x)
void print(const std::vector< T > &data)