8 modified files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.7 -r1.8
--- Helix.java 26 Mar 2009 20:58:41 -0000 1.7
+++ Helix.java 27 Mar 2009 19:52:55 -0000 1.8
@@ -9,7 +9,7 @@
* Helical {@link Trajectory} with its axis parallel to Z.
*
* @author D. Onoprienko
- * @version $Id: Helix.java,v 1.7 2009/03/26 20:58:41 onoprien Exp $
+ * @version $Id: Helix.java,v 1.8 2009/03/27 19:52:55 onoprien Exp $
*/
public class Helix extends AbstractTrajectory {
@@ -305,13 +305,12 @@
/** Returns intersection with <tt>ZDisk</tt>. */
public Intersection intersect(ZDisk zDisk) {
- double s = findLengthToZ(zDisk._z);
+ double s = findLengthToZ(zDisk.getZ());
if (Double.isInfinite(s)) return new IntersectionNone(this, zDisk);
Hep3Vector pos = getPosition(s);
- double x = pos.x();
- double y = pos.y();
- double r2 = x*x + y*y;
- return (r2 > zDisk._rMin2 && r2 < zDisk._rMax2) ? new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
+ double r = Math.hypot(pos.x(), pos.y());
+ return (r >= zDisk.getMinRadius() && r <= zDisk.getMaxRadius()) ?
+ new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
}
public Intersection intersect(ZCylinder zCylinder) {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.5 -r1.6
--- Line.java 27 Mar 2009 04:47:38 -0000 1.5
+++ Line.java 27 Mar 2009 19:52:55 -0000 1.6
@@ -8,7 +8,7 @@
* Straight line {@link Trajectory}.
*
* @author D. Onoprienko
- * @version $Id: Line.java,v 1.5 2009/03/27 04:47:38 onoprien Exp $
+ * @version $Id: Line.java,v 1.6 2009/03/27 19:52:55 onoprien Exp $
*/
public class Line extends AbstractTrajectory {
@@ -174,13 +174,12 @@
}
public Intersection intersect(ZDisk zDisk) {
- double s = (zDisk._z - _orig.z()) / _dir.z();
+ double s = (zDisk.getZ() - _orig.z()) / _dir.z();
if (Double.isInfinite(s)) return new IntersectionNone(this, zDisk);
Hep3Vector pos = getPosition(s);
- double x = pos.x();
- double y = pos.y();
- double r2 = x*x + y*y;
- return (r2 > zDisk._rMin2 && r2 < zDisk._rMax2) ? new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
+ double r = Math.hypot(pos.x(), pos.y());
+ return (r >= zDisk.getMinRadius() && r <= zDisk.getMaxRadius()) ?
+ new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
}
public Intersection intersect(ZCylinder zCylinder) {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- Poca.java 22 Jan 2009 21:01:58 -0000 1.2
+++ Poca.java 27 Mar 2009 19:52:55 -0000 1.3
@@ -9,7 +9,7 @@
* its constructor.
*
* @author D. Onoprienko
- * @version $Id: Poca.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: Poca.java,v 1.3 2009/03/27 19:52:55 onoprien Exp $
*/
public class Poca extends AbstractSurface {
@@ -55,6 +55,14 @@
return super.intersect(trajectory);
}
}
+
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ * Implemented to return the point supplied as an argument.
+ */
+ public Hep3Vector project(Hep3Vector point) {
+ return point;
+ }
// -- Private parts : ---------------------------------------------------------
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- PocaXY.java 22 Jan 2009 21:01:58 -0000 1.2
+++ PocaXY.java 27 Mar 2009 19:52:55 -0000 1.3
@@ -9,7 +9,7 @@
* point supplied to its constructor.
*
* @author D. Onoprienko
- * @version $Id: PocaXY.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: PocaXY.java,v 1.3 2009/03/27 19:52:55 onoprien Exp $
*/
public class PocaXY extends AbstractSurface {
@@ -56,6 +56,14 @@
}
}
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ * Implemented to return the point supplied as an argument.
+ */
+ public Hep3Vector project(Hep3Vector point) {
+ return point;
+ }
+
// -- Private parts : ---------------------------------------------------------
private ConstHep3Vector _point;
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- Surface.java 22 Jan 2009 21:01:58 -0000 1.2
+++ Surface.java 27 Mar 2009 19:52:55 -0000 1.3
@@ -1,16 +1,23 @@
package org.lcsim.contrib.onoprien.util.swim;
+import hep.physics.vec.Hep3Vector;
+
/**
* A surface in space.
*
* @author D. Onoprienko
- * @version $Id: Surface.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: Surface.java,v 1.3 2009/03/27 19:52:55 onoprien Exp $
*/
public interface Surface {
/**
* Returns intersection of the specified trajectory with this surface.
*/
- public Intersection intersect(Trajectory trajectory);
+ Intersection intersect(Trajectory trajectory);
+
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ */
+ Hep3Vector project(Hep3Vector point);
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.3 -r1.4
--- ZCylinder.java 26 Mar 2009 20:58:42 -0000 1.3
+++ ZCylinder.java 27 Mar 2009 19:52:55 -0000 1.4
@@ -8,15 +8,15 @@
* {@link Surface} that represents a bounded cylinder parallel to Z axis.
*
* @author D. Onoprienko
- * @version $Id: ZCylinder.java,v 1.3 2009/03/26 20:58:42 onoprien Exp $
+ * @version $Id: ZCylinder.java,v 1.4 2009/03/27 19:52:55 onoprien Exp $
*/
public class ZCylinder extends AbstractSurface {
// -- Private parts : ---------------------------------------------------------
- protected ConstHep3Vector _center;
- protected double _r;
- protected double _zHalf;
+ private ConstHep3Vector _center;
+ private double _r;
+ private double _zHalf;
// -- Constructors : ----------------------------------------------------------
@@ -98,5 +98,22 @@
return super.intersect(trajectory);
}
}
+
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ */
+ public Hep3Vector project(Hep3Vector point) {
+ double x = point.x() - _center.x();
+ double y = point.y() - _center.y();
+ double phi = Math.atan2(y, x);
+ double z = point.z();
+ double altZ;
+ if (z > (altZ = _center.z() + _zHalf)) {
+ z = altZ;
+ } else if (z < (altZ = _center.z() - _zHalf)) {
+ z = altZ;
+ }
+ return new ConstHep3Vector(_center.x()+_r*Math.cos(phi), _center.y()+_r*Math.sin(phi), z);
+ }
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- ZDisk.java 22 Jan 2009 21:01:58 -0000 1.2
+++ ZDisk.java 27 Mar 2009 19:52:55 -0000 1.3
@@ -1,19 +1,30 @@
package org.lcsim.contrib.onoprien.util.swim;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.ConstHep3Vector;
+
/**
* {@link Surface} that represents a disk centered around Z axis and perpendicular to it.
*
* @author D. Onoprienko
- * @version $Id: ZDisk.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: ZDisk.java,v 1.3 2009/03/27 19:52:55 onoprien Exp $
*/
public class ZDisk extends AbstractSurface {
-
+
+// -- Private parts : ---------------------------------------------------------
+
+ private double _z;
+ private double _rMin;
+ private double _rMax;
+
+
// -- Constructors : ----------------------------------------------------------
public ZDisk(double z, double radiusMin, double radiusMax) {
_z = z;
- _rMin2 = radiusMin * radiusMin;
- _rMax2 = radiusMax * radiusMax;
+ _rMin = radiusMin;
+ _rMax = radiusMax;
}
// -- Getters : ---------------------------------------------------------------
@@ -25,12 +36,12 @@
/** Returns inner radius of this disk. */
public double getMinRadius() {
- return Math.sqrt(_rMin2);
+ return _rMin;
}
/** Returns outer radius of this disk. */
public double getMaxRadius() {
- return Math.sqrt(_rMax2);
+ return _rMax;
}
// -- Implementing Surface : --------------------------------------------------
@@ -45,9 +56,20 @@
return super.intersect(trajectory);
}
}
-
-// -- Private parts : ---------------------------------------------------------
-
- double _z;
- double _rMin2, _rMax2;
+
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ */
+ public Hep3Vector project(Hep3Vector point) {
+ double r = Math.hypot(point.x(), point.y());
+ if (r > _rMax) {
+ double phi = Math.atan2(point.y(), point.x());
+ return new ConstHep3Vector(_rMax*Math.cos(phi), _rMax*Math.sin(phi), _z);
+ } else if (r < _rMin) {
+ double phi = Math.atan2(point.y(), point.x());
+ return new ConstHep3Vector(_rMin*Math.cos(phi), _rMin*Math.sin(phi), _z);
+ } else {
+ return new ConstHep3Vector(point.x(), point.y(), _z);
+ }
+ }
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.2 -r1.3
--- ZPlane.java 22 Jan 2009 21:01:58 -0000 1.2
+++ ZPlane.java 27 Mar 2009 19:52:55 -0000 1.3
@@ -1,10 +1,14 @@
package org.lcsim.contrib.onoprien.util.swim;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.ConstHep3Vector;
+
/**
* {@link Surface} that represents a plane perpendicular to Z axis.
*
* @author D. Onoprienko
- * @version $Id: ZPlane.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: ZPlane.java,v 1.3 2009/03/27 19:52:55 onoprien Exp $
*/
public class ZPlane extends AbstractSurface {
@@ -34,6 +38,13 @@
}
}
+ /**
+ * Returns the point on this surface that is closest to the specified point.
+ */
+ public Hep3Vector project(Hep3Vector point) {
+ return new ConstHep3Vector(point.x(), point.y(), _z);
+ }
+
// -- Private parts : ---------------------------------------------------------
double _z;
CVSspam 0.2.8