View Javadoc

1   /*
2    * SegmentationUtil.java Created on September 26, 2005, 12:11 PM
3    */
4   
5   package org.lcsim.geometry.segmentation;
6   
7   import static java.lang.Math.atan;
8   import static java.lang.Math.atan2;
9   import static java.lang.Math.PI;
10  import static java.lang.Math.sqrt;
11  
12  /**
13   * Utilities for segmentation classes.
14   * 
15   * @author jeremym
16   */
17  public final class SegmentationUtil
18  {
19      public static double getPhi(double x, double y)
20      {
21          double phi = atan2(x, y);
22  
23          if (phi < 0)
24          {
25              phi += 2 * PI;
26          }
27  
28          return phi;
29      }
30  
31      public static double getTheta(double x, double y, double z)
32      {
33          double theta = atan(getCylindricalRadius(x, y) / z);
34  
35          if (theta < 0)
36          {
37              theta += PI;
38          }
39  
40          return theta;
41      }
42  
43      public static double getCylindricalRadius(double x, double y)
44      {
45          return sqrt(x * x + y * y);
46      }
47  }