Print

Print


Commit in lcsim/src/org/lcsim/util/swim on MAIN
Helix.java+9-31.23 -> 1.24
Putting in Nick's fix.
The fix is not specific to the method, so we should take care that the other methods aren't subject to the same bug.

lcsim/src/org/lcsim/util/swim
Helix.java 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- Helix.java	15 Jul 2006 09:38:56 -0000	1.23
+++ Helix.java	27 Oct 2006 17:53:14 -0000	1.24
@@ -22,7 +22,7 @@
  * For more info on swimming see <a href="doc-files/transport.pdf">this paper</a>
  * by Paul Avery.
  * @author tonyj
- * @version $Id: Helix.java,v 1.23 2006/07/15 09:38:56 jstrube Exp $
+ * @version $Id: Helix.java,v 1.24 2006/10/27 17:53:14 jstrube Exp $
  */
 public class Helix implements Trajectory
 {
@@ -95,9 +95,15 @@
        // Negative radius doesn't make sense
       if (r<0) throw new IllegalArgumentException("radius "+r+"<0");
       double darg  = r*r/(2.*radius*radiusOfCenter) - radiusOfCenter/(2.*radius) - radius/(2.*radiusOfCenter);
-      double diff  = asin(darg) + phi - phiToCenter;
+      double deltaphi = phi - phiToCenter;
+      if (deltaphi < - Math.PI) 
+    	  deltaphi += 2.* Math.PI;
+      if (deltaphi > Math.PI) 
+    	  deltaphi -= 2.*Math.PI; 
+      double diff  = asin(darg) + deltaphi;
       double result = (radius/cosLambda)*diff;
-      while (result < 0) result += Math.abs(radius/cosLambda)*2*Math.PI;
+      while (result < 0)
+    	  result += Math.abs(radius/cosLambda)*2*Math.PI;
       return result;
    }
    
CVSspam 0.2.8