source: trunk/CLHEP/src/BoostY.cc@ 20

Last change on this file since 20 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 4.2 KB
Line 
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 the HepBoostY class.
7//
8
9#ifdef GNUPRAGMA
10#pragma implementation
11#endif
12
13#include "CLHEP/Vector/defs.h"
14#include "CLHEP/Vector/BoostY.h"
15#include "CLHEP/Vector/Boost.h"
16#include "CLHEP/Vector/Rotation.h"
17#include "CLHEP/Vector/LorentzRotation.h"
18#include "CLHEP/Vector/ZMxpv.h"
19
20namespace CLHEP {
21
22// ---------- Constructors and Assignment:
23
24HepBoostY & HepBoostY::set (double beta) {
25 double b2 = beta*beta;
26 if (b2 >= 1) {
27 ZMthrowA (ZMxpvTachyonic(
28 "Beta supplied to set HepBoostY represents speed >= c."));
29 beta_ = 1.0 - 1.0E-8; // NaN-proofing
30 gamma_ = 1.0 / sqrt(1.0 - b2);
31 return *this;
32 }
33 beta_ = beta;
34 gamma_ = 1.0 / sqrt(1.0 - b2);
35 return *this;
36}
37
38// ---------- Accessors:
39
40HepRep4x4 HepBoostY::rep4x4() const {
41 double bg = beta_*gamma_;
42 return HepRep4x4( 1, 0, 0, 0,
43 0, gamma_, 0, bg,
44 0, 0, 1, 0,
45 0, bg, 0, gamma_ );
46}
47
48HepRep4x4Symmetric HepBoostY::rep4x4Symmetric() const {
49 double bg = beta_*gamma_;
50 return HepRep4x4Symmetric ( 1, 0, 0, 0,
51 gamma_, 0, bg,
52 1, 0,
53 gamma_ );
54}
55
56// ---------- Decomposition:
57
58void HepBoostY::decompose (HepRotation & rotation, HepBoost & boost) const {
59 HepAxisAngle vdelta = HepAxisAngle();
60 rotation = HepRotation(vdelta);
61 Hep3Vector beta = boostVector();
62 boost = HepBoost(beta);
63}
64
65void HepBoostY::decompose (HepAxisAngle & rotation, Hep3Vector & boost) const {
66 rotation = HepAxisAngle();
67 boost = boostVector();
68}
69
70void HepBoostY::decompose (HepBoost & boost, HepRotation & rotation) const {
71 HepAxisAngle vdelta = HepAxisAngle();
72 rotation = HepRotation(vdelta);
73 Hep3Vector beta = boostVector();
74 boost = HepBoost(beta);
75}
76
77void HepBoostY::decompose (Hep3Vector & boost, HepAxisAngle & rotation) const {
78 rotation = HepAxisAngle();
79 boost = boostVector();
80}
81
82// ---------- Comparisons:
83
84double HepBoostY::distance2( const HepBoost & b ) const {
85 return b.distance2(*this);
86}
87
88double HepBoostY::distance2( const HepRotation & r ) const {
89 double db2 = norm2();
90 double dr2 = r.norm2();
91 return (db2 + dr2);
92}
93
94double HepBoostY::distance2( const HepLorentzRotation & lt ) const {
95 HepBoost b1;
96 HepRotation r1;
97 lt.decompose(b1,r1);
98 double db2 = distance2(b1);
99 double dr2 = r1.norm2();
100 return (db2 + dr2);
101}
102
103bool HepBoostY::isNear (const HepRotation & r, double epsilon) const {
104 double db2 = norm2();
105 if (db2 > epsilon*epsilon) return false;
106 double dr2 = r.norm2();
107 return (db2+dr2 <= epsilon*epsilon);
108}
109
110bool HepBoostY::isNear ( const HepLorentzRotation & lt,
111 double epsilon ) const {
112 HepBoost b1;
113 HepRotation r1;
114 double db2 = distance2(b1);
115 lt.decompose(b1,r1);
116 if (db2 > epsilon*epsilon) return false;
117 double dr2 = r1.norm2();
118 return (db2 + dr2);
119}
120
121// ---------- Properties:
122
123void HepBoostY::rectify() {
124 // Assuming the representation of this is close to a true pure boost,
125 // but may have drifted due to round-off error from many operations,
126 // this forms an "exact" pure BoostY matrix for again.
127
128 double b2 = beta_*beta_;
129 if (b2 >= 1) {
130 beta_ = 1.0 - 1.0e-8; // Nan-proofing
131 b2 = beta_*beta_;
132 }
133 gamma_ = 1.0 / sqrt(1.0 - b2);
134}
135
136// ---------- Application:
137
138// ---------- Operations in the group of 4-Rotations
139
140HepBoostY HepBoostY::operator * (const HepBoostY & b) const {
141 return HepBoostY ( (beta()+b.beta()) / (1+beta()*b.beta()) );
142}
143HepLorentzRotation HepBoostY::operator * (const HepBoost & b) const {
144 HepLorentzRotation me (*this);
145 return me*b;
146}
147HepLorentzRotation HepBoostY::operator * (const HepRotation & r) const {
148 HepLorentzRotation me (*this);
149 return me*r;
150}
151HepLorentzRotation HepBoostY::operator * (const HepLorentzRotation & lt) const {
152 HepLorentzRotation me (*this);
153 return me*lt;
154}
155
156// ---------- I/O
157
158std::ostream & HepBoostY::print( std::ostream & os ) const {
159 os << "Boost in Y direction (beta = " << beta_
160 << ", gamma = " << gamma_ << ") ";
161 return os;
162}
163
164} // namespace CLHEP
Note: See TracBrowser for help on using the repository browser.