View Javadoc

1   /*
2    * RotationGeant.java
3    *
4    * Created on July 31, 2007, 3:45 PM
5    *
6    * To change this template, choose Tools | Template Manager
7    * and open the template in the editor.
8    */
9   
10  package org.lcsim.detector;
11  
12  import hep.physics.vec.Hep3Vector;
13  import hep.physics.vec.BasicHep3Vector;
14  
15  /**
16   *
17   * Represents a rotation in 3D space according to the Geant4 conventions.
18   *
19   * @author Tim Nelson <tknelson@slac.stanford.edu>
20   */
21  public class RotationGeant extends Rotation3D
22  {
23      
24      /** Creates a new instance of RotationGeant */
25      public RotationGeant(double a, double b, double c)
26      {
27          super(makeRotation(a,b,c));
28      }
29      
30      // Static Method
31      //===============
32      public static IRotation3D makeRotation(double phi, double theta, double psi)
33      {
34          Hep3Vector x_axis = new BasicHep3Vector(1,0,0);
35          Hep3Vector y_axis = new BasicHep3Vector(0,1,0);
36          Hep3Vector z_axis = new BasicHep3Vector(0,0,1);
37          
38          // Rotate around body x_axis
39          IRotation3D rotation = passiveAxisRotation(phi,x_axis);
40          
41          // Rotate around body y_axis
42          rotation = Rotation3D.multiply(passiveAxisRotation(theta,rotation.rotated(y_axis)),rotation);
43  
44          // Rotate around body z_axis
45          rotation = Rotation3D.multiply(passiveAxisRotation(psi,rotation.rotated(z_axis)),rotation);
46          
47          return rotation;
48      }
49      
50  }