12 #pragma implementation
15 #include "CLHEP/Vector/ThreeVector.h"
16 #include "CLHEP/Vector/AxisAngle.h"
17 #include "CLHEP/Vector/EulerAngles.h"
25 Hep3Vector & Hep3Vector::rotate (
const Hep3Vector & axis,
27 double r1 = axis.mag();
29 std::cerr <<
"Hep3Vector::rotate() - "
30 <<
"Attempt to rotate around a zero vector axis! " << std::endl;
33 register double scale=1.0/r1;
34 register double ux = scale*axis.getX();
35 register double uy = scale*axis.getY();
36 register double uz = scale*axis.getZ();
37 double cd = std::cos(ddelta);
38 double sd = std::sin(ddelta);
39 register double ocd = 1 -
cd;
44 {
register double ocdux = ocd * ux;
45 rx = dx * ( cd + ocdux * ux ) +
46 dy * ( ocdux * uy - sd * uz ) +
47 dz * ( ocdux * uz + sd * uy ) ;
50 {
register double ocduy = ocd * uy;
51 ry = dy * ( cd + ocduy * uy ) +
52 dz * ( ocduy * uz - sd * ux ) +
53 dx * ( ocduy * ux + sd * uz ) ;
56 {
register double ocduz = ocd * uz;
57 rz = dz * ( cd + ocduz * uz ) +
58 dx * ( ocduz * ux - sd * uy ) +
59 dy * ( ocduz * uy + sd * ux ) ;
74 Hep3Vector & Hep3Vector::rotate (
double phi1,
82 register double sinPhi = std::sin( phi1 ), cosPhi = std::cos( phi1 );
83 register double sinTheta = std::sin( theta1 ), cosTheta1 = std::cos( theta1 );
84 register double sinPsi = std::sin( psi1 ), cosPsi = std::cos( psi1 );
86 rx = (cosPsi * cosPhi - cosTheta1 * sinPsi * sinPhi) * dx +
87 (cosPsi * sinPhi + cosTheta1 * sinPsi * cosPhi) * dy +
88 (sinPsi * sinTheta) * dz ;
90 ry = (- sinPsi * cosPhi - cosTheta1 * cosPsi * sinPhi) * dx +
91 (- sinPsi * sinPhi + cosTheta1 * cosPsi * cosPhi) * dy +
92 (cosPsi * sinTheta) * dz ;
94 rz = (sinTheta * sinPhi) * dx +
95 (- sinTheta * cosPhi) * dy +
112 Hep3Vector & Hep3Vector::rotate (
const HepAxisAngle & ax ) {
113 return rotate( ax.getAxis(), ax.delta() );
116 Hep3Vector & Hep3Vector::rotate (
const HepEulerAngles & ex ) {
117 return rotate( ex.phi(), ex.theta(), ex.psi() );
127 Hep3Vector
rotationOf (
const Hep3Vector & vec,
const HepAxisAngle & ax) {
129 return vv.rotate (ax);
133 const Hep3Vector & axis,
double ddelta) {
135 return vv.rotate(axis, ddelta);
138 Hep3Vector
rotationOf (
const Hep3Vector & vec,
const HepEulerAngles & ex) {
140 return vv.rotate (ex);
144 double phi,
double theta,
double psi) {
146 return vv.rotate(phi, theta, psi);
151 return vv.rotateX (ddelta);
156 return vv.rotateY (ddelta);
161 return vv.rotateZ (ddelta);
HepLorentzVector rotationOf(const HepLorentzVector &vec, const Hep3Vector &aaxis, double ddelta)
HepLorentzVector rotationXOf(const HepLorentzVector &vec, double phi)
HepLorentzVector rotationZOf(const HepLorentzVector &vec, double phi)
HepLorentzVector rotationYOf(const HepLorentzVector &vec, double phi)