Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim on MAIN |
Helix.java | +21 | -13 | 1.6 -> 1.7 |
Line.java | +2 | -2 | 1.3 -> 1.4 |
ZCylinder.java | +60 | -12 | 1.2 -> 1.3 |
| +83 | -27 | |
3 modified files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.6 -r1.7
--- Helix.java 26 Feb 2009 19:01:28 -0000 1.6
+++ Helix.java 26 Mar 2009 20:58:41 -0000 1.7
@@ -9,7 +9,7 @@
* Helical {@link Trajectory} with its axis parallel to Z.
*
* @author D. Onoprienko
- * @version $Id: Helix.java,v 1.6 2009/02/26 19:01:28 onoprien Exp $
+ * @version $Id: Helix.java,v 1.7 2009/03/26 20:58:41 onoprien Exp $
*/
public class Helix extends AbstractTrajectory {
@@ -257,6 +257,8 @@
return intersect((Poca) surface);
} else if (surface instanceof PocaXY) {
return intersect((PocaXY) surface);
+ } else if (surface instanceof ZDisk) {
+ return intersect((ZDisk) surface);
} else if (surface instanceof ZPlane) {
return intersect((ZPlane) surface);
} else if (surface instanceof ZCylinder) {
@@ -288,10 +290,10 @@
double sin = - (_ro*a2)/a12;
double s = getLength(sin,cos);
- double nx = _dir.x()/_ro;
- double ny = _dir.y()/_ro;
- double x = _orig.x() + nx * sin + ny * (1-cos);
- double y = _orig.y() + ny * sin - nx * (1-cos);
+// double nx = _dir.x()/_ro;
+// double ny = _dir.y()/_ro;
+// double x = _orig.x() + nx * sin + ny * (1-cos);
+// double y = _orig.y() + ny * sin - nx * (1-cos);
return new IntersectionSingle(s, this, poca);
}
@@ -312,12 +314,18 @@
return (r2 > zDisk._rMin2 && r2 < zDisk._rMax2) ? new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
}
- public Intersection intersect(ZCylinder zCylinder) { // FIXME
-
- double ro2 = _c*_c;
- double a1 = 1. - _dir.z()*_dir.z() - _c*(_orig.x()*_dir.y() + _orig.y()*_dir.x());
- double a2 = _orig.x()*_dir.x() - _orig.y()*_dir.y();
- double deltaR = _orig.x()*_orig.x() + _orig.y()*_orig.y() - zCylinder._r*zCylinder._r;
+ public Intersection intersect(ZCylinder zCylinder) {
+
+ double r = zCylinder.getRadius();
+ Hep3Vector center = zCylinder.getCenter();
+
+ double deltaX = _orig.x() - center.x();
+ double deltaY = _orig.y() - center.y();
+ double a1 = 1. - _dir.z()*_dir.z() + _ro*(_dir.y()*deltaX-_dir.x()*deltaY);
+ double a2 = _dir.x()*deltaX + _dir.y()*deltaY;
+
+ double deltaR = deltaX*deltaX + deltaY*deltaY - r*r;
+ double ro2 = _ro*_ro;
double a12 = a1*a1 + ro2*a2*a2;
double d = 4.*a2*a2 - 4.*deltaR*a1 - ro2*deltaR*deltaR;
if (d < 0.) return new IntersectionNone(this, zCylinder);
@@ -326,8 +334,8 @@
double cos1 = 1. - (ro2* (2.*a2*a2 - deltaR*a1 + a2*d) ) / (2.*a12);
double cos2 = 1. - (ro2* (2.*a2*a2 - deltaR*a1 - a2*d) ) / (2.*a12);
- double sin1 = (- _c* (2.*a1*a2 + ro2*deltaR*a2 + a1*d)) / (2.*a12);
- double sin2 = (- _c* (2.*a1*a2 + ro2*deltaR*a2 - a1*d)) / (2.*a12);
+ double sin1 = (- _ro* (2.*a1*a2 + ro2*deltaR*a2 + a1*d)) / (2.*a12);
+ double sin2 = (- _ro* (2.*a1*a2 + ro2*deltaR*a2 - a1*d)) / (2.*a12);
double s1 = getLength(sin1, cos1);
double s2 = getLength(sin2, cos2);
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.3 -r1.4
--- Line.java 17 Mar 2009 16:57:00 -0000 1.3
+++ Line.java 26 Mar 2009 20:58:41 -0000 1.4
@@ -8,7 +8,7 @@
* Straight line {@link Trajectory}.
*
* @author D. Onoprienko
- * @version $Id: Line.java,v 1.3 2009/03/17 16:57:00 onoprien Exp $
+ * @version $Id: Line.java,v 1.4 2009/03/26 20:58:41 onoprien Exp $
*/
public class Line extends AbstractTrajectory {
@@ -198,7 +198,7 @@
good[i] = false;
} else {
double z = getPosition(s).z();
- good[i] = z > zCylinder._zMin && z < zCylinder._zMax;
+ good[i] = z > zCylinder.getMinZ() && z < zCylinder.getMaxZ();
}
}
if (good[0] && good[1]) {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- ZCylinder.java 22 Jan 2009 21:01:58 -0000 1.2
+++ ZCylinder.java 26 Mar 2009 20:58:42 -0000 1.3
@@ -1,36 +1,89 @@
package org.lcsim.contrib.onoprien.util.swim;
+import hep.physics.vec.Hep3Vector;
+
import org.lcsim.contrib.onoprien.util.ConstHep3Vector;
/**
- * {@link Surface} that represents a bounded cylinder parallel to and centered at Z axis.
- * This surface is characterized by radius, low Z bound, and high Z bound.
+ * {@link Surface} that represents a bounded cylinder parallel to Z axis.
*
* @author D. Onoprienko
- * @version $Id: ZCylinder.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: ZCylinder.java,v 1.3 2009/03/26 20:58:42 onoprien Exp $
*/
public class ZCylinder extends AbstractSurface {
+
+// -- Private parts : ---------------------------------------------------------
+
+ protected ConstHep3Vector _center;
+ protected double _r;
+ protected double _zHalf;
// -- Constructors : ----------------------------------------------------------
-
+
+ /**
+ * Constructs a cylinder centered around Z axis.
+ * @param radius Cylinder radius.
+ * @param zMin Lower Z boundary.
+ * @param zMax Higher Z boundary.
+ */
public ZCylinder(double radius, double zMin, double zMax) {
+ if (radius <= 0. || zMin >= zMax) throw new IllegalArgumentException();
+ _r = radius;
+ _zHalf = (zMax - zMin) / 2.;
+ double z = (zMax + zMin) / 2.;
+ _center = new ConstHep3Vector(0., 0., z);
+ }
+
+ /**
+ * Constructs a cylinder with a center at the global coordinate system origin.
+ * @param radius Cylinder radius.
+ * @param zHalf Half-length in Z.
+ */
+ public ZCylinder(double radius, double zHalf) {
+ if (radius <= 0. || zHalf <= 0.) throw new IllegalArgumentException();
+ _r = radius;
+ _zHalf = zHalf;
+ _center = ConstHep3Vector.V000;
+ }
+
+ /**
+ * Constract a ZCylinder.
+ * @param center Center of the cylinder.
+ * @param radius Cylinder radius.
+ * @param zHalf Half-length in Z.
+ */
+ public ZCylinder(Hep3Vector center, double radius, double zHalf) {
+ if (radius <= 0. || zHalf <= 0.) throw new IllegalArgumentException();
+ _center = (center instanceof ConstHep3Vector) ? (ConstHep3Vector)center : new ConstHep3Vector(center);
+ _r = radius;
+ _zHalf = zHalf;
}
// -- Getters : ---------------------------------------------------------------
-
+
+ /** Returns the center point of this cylinder. */
+ public ConstHep3Vector getCenter() {
+ return _center;
+ }
+
/** Returns radius of this cylinder. */
public double getRadius() {
return _r;
}
+
+ /** Returns half-length of this cylinder. */
+ public double getHalfZ() {
+ return _zHalf;
+ }
/** Returns minimum Z of this cylinder. */
public double getMinZ() {
- return _zMin;
+ return _center.z() - _zHalf;
}
/** Returns minimum Z of this cylinder. */
public double getMaxZ() {
- return _zMax;
+ return _center.z() + _zHalf;
}
// -- Implementing Surface : --------------------------------------------------
@@ -46,9 +99,4 @@
}
}
-// -- Private parts : ---------------------------------------------------------
-
- double _r;
- double _zMin, _zMax;
-
}
CVSspam 0.2.8