Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:35

0001 #include <iostream>
0002 #include <vector>
0003 #include <cmath>
0004 #include <CLHEP/Vector/ThreeVector.h>
0005 #include <CLHEP/Vector/Rotation.h>
0006 #include <CLHEP/Units/SystemOfUnits.h>
0007 
0008 using namespace std;
0009 
0010 /* 
0011   print a rotationmatrix in phiX, thetaX, phiY, ... representation
0012   when given in an (rotation-axis, rotation-angle)-representation
0013 */
0014 int main() {
0015   double phi, theta, alpha;
0016 
0017   cout << " axis:    phi[deg]=";
0018   cin >> phi;
0019   phi = phi * deg;
0020   cout << " axis:  theta[deg]=";
0021   cin >> theta;
0022   theta = theta * deg;
0023   cout << " angle: alpha[deg]=";
0024   cin >> alpha;
0025   alpha = alpha * deg;
0026   cout << endl;
0027   CLHEP::Hep3Vector axis;
0028   axis[0] = cos(phi) * sin(theta);
0029   axis[1] = sin(phi) * sin(theta);
0030   axis[2] = cos(theta);
0031   cout << " axis: (" << axis[0] << ',' << axis[1] << ',' << axis[2] << ')' << endl;
0032   CLHEP::HepRotation rot(axis, alpha);
0033   cout << endl;
0034   cout << "<Rotation name=\"YourNameHere\"" << endl;
0035   cout << "  phiX=\"" << rot.phiX() / deg << "*deg\"" << endl;
0036   cout << "  thetaX=\"" << rot.thetaX() / deg << "*deg\"" << endl;
0037   cout << "  phiY=\"" << rot.phiY() / deg << "*deg\"" << endl;
0038   cout << "  thetaY=\"" << rot.thetaY() / deg << "*deg\"" << endl;
0039   cout << "  phiZ=\"" << rot.phiZ() / deg << "*deg\"" << endl;
0040   cout << "  thetaZ=\"" << rot.thetaZ() / deg << "*deg\"/>" << endl;
0041 
0042   return 0;
0043 }