GeomConverter/src/org/lcsim/geometry/segmentation
diff -N SegmentationUtil.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SegmentationUtil.java 26 Sep 2005 19:24:05 -0000 1.1
@@ -0,0 +1,51 @@
+/*
+ * SegmentationUtil.java
+ *
+ * Created on September 26, 2005, 12:11 PM
+ */
+
+package org.lcsim.geometry.segmentation;
+
+import static java.lang.Math.atan;
+import static java.lang.Math.atan2;
+import static java.lang.Math.PI;
+import static java.lang.Math.sqrt;
+
+/**
+ *
+ * @author jeremym
+ */
+public final class SegmentationUtil
+{
+ private SegmentationUtil()
+ {}
+
+ public static double getPhi(double x, double y)
+ {
+ double phi = atan2(x, y);
+
+ if ( phi < 0 )
+ {
+ phi += 2 * PI;
+ }
+
+ return phi;
+ }
+
+ public static double getTheta(double x, double y, double z)
+ {
+ double theta = atan(getCylindricalRadius(x, y) / z );
+
+ if ( theta < 0 )
+ {
+ theta += PI;
+ }
+
+ return theta;
+ }
+
+ public static double getCylindricalRadius(double x, double y)
+ {
+ return sqrt(x * x + y * y);
+ }
+}
GeomConverter/src/org/lcsim/geometry/segmentation
diff -u -r1.14 -r1.15
--- GridXYZ.java 24 Jul 2005 06:47:42 -0000 1.14
+++ GridXYZ.java 26 Sep 2005 19:24:05 -0000 1.15
@@ -76,31 +76,15 @@
{
return new long[3];
}
-
- /** FIXME: Doesn't belong here, as it is always generally derivable from x and y. */
+
public double getPhi()
{
- double phi = atan2(getX(), getY() );
-
- if ( phi < 0 )
- {
- phi += 2 * PI;
- }
-
- return phi;
+ return SegmentationUtil.getPhi(getX(), getY() );
}
- /** FIXME: Doesn't belong here, as it is always computable given x and y. */
public double getTheta()
{
- double theta = atan(getCylindricalRadiusFromPosition() / getZ() );
-
- if ( theta < 0 )
- {
- theta += PI;
- }
-
- return theta;
+ return SegmentationUtil.getTheta(getX(), getY(), getZ() );
}
public double getX()