18 #pragma implementation
21 #include "CLHEP/Vector/ThreeVector.h"
22 #include "CLHEP/Units/PhysicalConstants.h"
35 void Hep3Vector::setSpherical (
49 dz = r1 * std::cos(theta1);
50 double rho1 ( r1*std::sin(theta1));
51 dy = rho1 * std::sin (phi1);
52 dx = rho1 * std::cos (phi1);
56 void Hep3Vector::setCylindrical (
66 dy = rho1 * std::sin (phi1);
67 dx = rho1 * std::cos (phi1);
71 void Hep3Vector::setRhoPhiTheta (
76 std::cerr <<
"Hep3Vector::setRhoPhiTheta() - "
77 <<
"Attempt set vector components rho, phi, theta with zero rho -- "
78 <<
"zero vector is returned, ignoring theta and phi" << std::endl;
79 dx = 0; dy = 0; dz = 0;
92 dz = rho1 / std::tan (theta1);
93 dy = rho1 * std::sin (phi1);
94 dx = rho1 * std::cos (phi1);
98 void Hep3Vector::setRhoPhiEta (
103 std::cerr <<
"Hep3Vector::setRhoPhiEta() - "
104 <<
"Attempt set vector components rho, phi, eta with zero rho -- "
105 <<
"zero vector is returned, ignoring eta and phi" << std::endl;
106 dx = 0; dy = 0; dz = 0;
109 double theta1 (2 * std::atan ( std::exp (-eta1) ));
110 dz = rho1 / std::tan (theta1);
111 dy = rho1 * std::sin (phi1);
112 dx = rho1 * std::cos (phi1);
122 int Hep3Vector::compare (
const Hep3Vector & v)
const {
125 }
else if ( dz < v.dz ) {
127 }
else if ( dy > v.dy ) {
129 }
else if ( dy < v.dy ) {
131 }
else if ( dx > v.dx ) {
133 }
else if ( dx < v.dx ) {
141 bool Hep3Vector::operator > (
const Hep3Vector & v)
const {
142 return (compare(v) > 0);
145 return (compare(v) < 0);
147 bool Hep3Vector::operator>= (
const Hep3Vector & v)
const {
148 return (compare(v) >= 0);
150 bool Hep3Vector::operator<= (
const Hep3Vector & v)
const {
151 return (compare(v) <= 0);
168 double Hep3Vector::howParallel (
const Hep3Vector & v)
const {
170 double v1v2 = std::fabs(dot(v));
173 return ( (mag2() == 0) && (v.mag2() == 0) ) ? 0 : 1;
175 Hep3Vector v1Xv2 ( cross(v) );
176 double abscross = v1Xv2.mag();
177 if ( abscross >= v1v2 ) {
180 return abscross/v1v2;
184 bool Hep3Vector::isParallel (
const Hep3Vector & v,
185 double epsilon)
const {
189 static const double TOOBIG = std::pow(2.0,507);
190 static const double SCALE = std::pow(2.0,-507);
191 double v1v2 = std::fabs(dot(v));
193 return ( (mag2() == 0) && (v.mag2() == 0) );
195 if ( v1v2 >= TOOBIG ) {
196 Hep3Vector sv1 ( *
this * SCALE );
197 Hep3Vector sv2 ( v * SCALE );
198 Hep3Vector sv1Xsv2 = sv1.cross(sv2);
199 double x2 = sv1Xsv2.mag2();
200 double limit = v1v2*SCALE*SCALE;
201 limit = epsilon*epsilon*limit*limit;
202 return ( x2 <= limit );
207 Hep3Vector v1Xv2 ( cross(v) );
208 if ( (std::fabs (v1Xv2.dx) > TOOBIG) ||
209 (std::fabs (v1Xv2.dy) > TOOBIG) ||
210 (std::fabs (v1Xv2.dz) > TOOBIG) ) {
214 return ( (v1Xv2.mag2()) <= ((epsilon * v1v2) * (epsilon * v1v2)) );
219 double Hep3Vector::howOrthogonal (
const Hep3Vector & v)
const {
222 double v1v2 = std::fabs(dot(v));
227 Hep3Vector v1Xv2 ( cross(v) );
228 double abscross = v1Xv2.mag();
229 if ( v1v2 >= abscross ) {
232 return v1v2/abscross;
237 bool Hep3Vector::isOrthogonal (
const Hep3Vector & v,
238 double epsilon)
const {
242 static const double TOOBIG = std::pow(2.0,507);
243 static const double SCALE = std::pow(2.0,-507);
244 double v1v2 = std::fabs(dot(v));
246 if ( v1v2 >= TOOBIG ) {
247 Hep3Vector sv1 ( *
this * SCALE );
248 Hep3Vector sv2 ( v * SCALE );
249 Hep3Vector sv1Xsv2 = sv1.cross(sv2);
250 double x2 = sv1Xsv2.mag2();
251 double limit = epsilon*epsilon*x2;
252 double y2 = v1v2*SCALE*SCALE;
253 return ( y2*y2 <= limit );
258 Hep3Vector eps_v1Xv2 ( cross(epsilon*v) );
259 if ( (std::fabs (eps_v1Xv2.dx) > TOOBIG) ||
260 (std::fabs (eps_v1Xv2.dy) > TOOBIG) ||
261 (std::fabs (eps_v1Xv2.dz) > TOOBIG) ) {
267 return ( v1v2*v1v2 <= eps_v1Xv2.mag2() );
271 double Hep3Vector::setTolerance (
double tol) {
273 double oldTolerance (tolerance);
283 double Hep3Vector::negativeInfinity()
const {
297 for (k=0; k<8; k++) {
298 value.u.i[k] = negOne.u.i[k] | posTwo.u.i[k];
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)