Commit in lcsim/src/org/lcsim/contrib/JanStrube/tracking on MAIN
Helix.java+18-71.8 -> 1.9
Modified getSignedClosestDifferenceToPoint to eliminate use of while loops to find remainder.

lcsim/src/org/lcsim/contrib/JanStrube/tracking
Helix.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- Helix.java	7 Dec 2006 06:11:24 -0000	1.8
+++ Helix.java	12 Jul 2007 22:02:03 -0000	1.9
@@ -25,7 +25,7 @@
  * by Paul Avery.
  * 
  * @author tonyj
- * @version $Id: Helix.java,v 1.8 2006/12/07 06:11:24 jstrube Exp $
+ * @version $Id: Helix.java,v 1.9 2007/07/12 22:02:03 tknelson Exp $
  */
 public class Helix implements Trajectory {
     Hep3Vector origin;
@@ -176,15 +176,26 @@
 
         // translate along Z because algorithm can handle only numbers in the
         // first quadrant
+
+        // modified to get rid of while loops by Tim Nelson and Cosmin Deaconu
         double zPos = xDiff.z();
-        // these are two mutually exclusive cases and two while loops
-        // may not be the best way to express this
-        while (zPos > abs(radius * tanLambda * Math.PI / 4)) {
-            zPos -= abs(radius * tanLambda * Math.PI / 4);
+        if (zPos > 0)
+        {
+            zPos = Math.IEEEremainder(zPos,abs(radius * tanLambda * Math.PI / 4));
         }
-        while (zPos < -abs(radius * tanLambda * Math.PI / 4)) {
-            zPos += abs(radius * tanLambda * Math.PI / 4);
+        else
+        {
+            zPos = Math.abs(radius * tanLambda * Math.PI / 4) - Math.IEEEremainder(zPos,abs(radius * tanLambda * Math.PI / 4));
         }
+        
+        // these are two mutually exclusive cases and two while loops
+        // may not be the best way to express this
+//        while (zPos > abs(radius * tanLambda * Math.PI / 4)) {
+//            zPos -= abs(radius * tanLambda * Math.PI / 4);
+//        }
+//        while (zPos < -abs(radius * tanLambda * Math.PI / 4)) {
+//            zPos += abs(radius * tanLambda * Math.PI / 4);
+//        }
         xDiff = new CartesianVector(xDiff.x(), xDiff.y(), zPos);
 
         double numerator = (-2 * VecOp.dot(xDiff, pCrossB) + pMag * rho
CVSspam 0.2.8