Commit in projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd on MAIN | |||
HPSTestRunTracker2014.java | +385 | -98 | 3120 -> 3121 |
Some more tests; will need cleanup.
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-05-08 23:45:20 UTC (rev 3120) +++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java 2014-05-09 23:01:45 UTC (rev 3121) @@ -1,18 +1,19 @@
package org.lcsim.geometry.compact.converter.lcdd;
+import static java.lang.Math.PI;
import hep.physics.vec.BasicHep3Matrix; import hep.physics.vec.BasicHep3Vector; import hep.physics.vec.Hep3Matrix; import hep.physics.vec.Hep3Vector; import hep.physics.vec.VecOp;
-
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map;
+import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.jdom.Element; import org.jdom.JDOMException; import org.lcsim.detector.ITransform3D;
@@ -185,19 +186,38 @@
VolWrapper trackingWrap = new VolWrapper(); trackingWrap.name = "trackingVolume"; trackingWrap.vol = trackingVolume;
-
+ CoordSysDef coord_tracking = new CoordSysDef(new BasicHep3Vector(0,0,0),new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1)); + trackingWrap.coord = coord_tracking; + trackingWrap.center = new BasicHep3Vector(0,0,0); + + + if(_debug) { + print(String.format("coord_tracking:\n%s", coord_tracking.toString())); + } + +
// Surveyed position of the base plate in the JLab/tracking volume
- // Use edges of plate instead of real survey balls - Hep3Vector ball_pos_base_plate = new BasicHep3Vector(-1*this.base_plate_width/2.0, -1.0*this.base_height/2.0+this.base_plate_thickness,this.base_length/2.0); - Hep3Vector vee_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x()+this.base_plate_width,ball_pos_base_plate.y(),ball_pos_base_plate.z()); - Hep3Vector flat_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x(),ball_pos_base_plate.y(),ball_pos_base_plate.z()-this.base_plate_length);
+ // Use edges of plate instead of real survey balls for now + // Defined so that the local coordinate system of the base plate is oriented as + // width - u - global x + // length - v - global -z + // thickness - w - global y
+ Hep3Vector ball_pos_base_plate = new BasicHep3Vector(0,0,0); + Hep3Vector vee_pos_base_plate = new BasicHep3Vector(base_plate_width,ball_pos_base_plate.y(),ball_pos_base_plate.z()); + Hep3Vector flat_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x(), ball_pos_base_plate.y(), ball_pos_base_plate.z() - base_plate_length); + + // Hep3Vector ball_pos_base_plate = new BasicHep3Vector(-1*this.base_plate_width/2.0, -1.0*this.base_height/2.0+this.base_plate_thickness,this.base_length/2.0); +// Hep3Vector vee_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x()+this.base_plate_width,ball_pos_base_plate.y(),ball_pos_base_plate.z()); +// Hep3Vector flat_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x(),ball_pos_base_plate.y(),ball_pos_base_plate.z()-this.base_plate_length);
+ makeExample(lcdd,sens); +
makeBase(trackingWrap, ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate, lcdd, sens );
- org.apache.commons.math3.geometry.euclidean.threed.Rotation dummyrot = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(3.0,1.0,1.0,1.0,true);
+
@@ -208,6 +228,126 @@
+ + + private void makeExample(LCDD lcdd, SensitiveDetector sens) throws JDOMException { + + + if(_debug) { + print("--- makeExample ----"); + + } + + + + String volName = "example"; + Box box = new Box(volName + "Box", base_width, base_length , base_height/4.0); + lcdd.add(box); + Volume baseVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum")); + + + + org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisX = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1., 0., 0.); + org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisY = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0., 1., 0.); + org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisZ = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0., 0., 1.); + + double alpha1 = PI / 4.; + double alpha2 = PI / 4.; + double alpha3 = -PI / 4.; + + //set up a rotation by alpha1 about the X axis + org.apache.commons.math3.geometry.euclidean.threed.Rotation r1 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(axisX, alpha1); + + // find y' and z' + org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisYPrime = r1.applyTo(axisY); + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisZPrime = r1.applyTo(axisZ); + + if(_debug) System.out.println("axisYPrime: " + axisYPrime); + //if(_debug) System.out.println("axisZPrime: " + axisZPrime); + + //set up a rotation by alpha2 about the Y' axis + org.apache.commons.math3.geometry.euclidean.threed.Rotation r2 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(axisYPrime, alpha2); + + //find z'' + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisZPrimePrime = r2.applyTo(axisZPrime); + //if(_debug) System.out.println("axisZPrimePrime: " + axisZPrimePrime); + + + + //set up a rotation by alpha3 about the Z'' axis + //org.apache.commons.math3.geometry.euclidean.threed.Rotation r3 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(axisZPrimePrime, alpha3); + + if(_debug) System.out.println("r1 (XYZ): " + r1.toString()); + + org.apache.commons.math3.geometry.euclidean.threed.Rotation r12 = r2.applyTo(r1); + + //find z'' + org.apache.commons.math3.geometry.euclidean.threed.Vector3D axisZPrimePrime = r12.applyTo(axisZ); + if(_debug) System.out.println("axisZPrimePrime: " + axisZPrimePrime); + org.apache.commons.math3.geometry.euclidean.threed.Rotation r3 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(axisZPrimePrime, alpha3); + + + org.apache.commons.math3.geometry.euclidean.threed.Rotation r123 = r3.applyTo(r12); + + //double [] rotations = r12.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + double [] rotations = r123.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + + Position pos = new Position(volName + "_position",0,0,0); + Rotation rot = new Rotation(volName + "_rotation",rotations[0],rotations[1],rotations[2]); + lcdd.add(pos); + lcdd.add(rot); + + + PhysVol basePV = new PhysVol(baseVolume, lcdd.pickMotherVolume(this), pos, rot); + + + lcdd.add(baseVolume); + + + + /* + + // Find distance to center in the local coordinate system + Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, base_height/2.0); + + Position pos = new Position(volName + "_position",0,0,0); + + + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u.v()); + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v.v()); + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u_prime.v()); + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v_prime.v()); + //org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1,0,0); + //org.apache.commons.math3.geometry.euclidean.threed.Rotation rot = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(u_3D,v_3D,u_prime_3D,v_prime_3D); + //double res[] = rot.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + + //org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_cardan = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,Math.PI/4.0,0,0); + + + //Find LCDD Euler rotation angles from coordinate system unit vectors + Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); + getEulerAngles(new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0)); + //Hep3Vector lcdd_rot_angles = getEulerAngles(new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0)); + //Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()); + //Rotation rot = new Rotation(volName + "_rotation",0,Math.PI/4.0,Math.PI/2.0); + Rotation rot = new Rotation(volName + "_rotation",0,0,0); + lcdd.add(pos); + lcdd.add(rot); + + // Create the physical volume + PhysVol basePV = new PhysVol(baseVolume, lcdd.pickMotherVolume(this), pos, rot); + + + lcdd.add(baseVolume); + + */ + + } + + + + +
private void makeBase(VolWrapper trackingWrap, Hep3Vector ball_pos_base_plate, Hep3Vector vee_pos_base_plate, Hep3Vector flat_pos_base_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
@@ -217,57 +357,88 @@
print("--- makeBase ----"); }
+
+ // create the coordinate system of the SVT tracking box called "base" in the tracking volume + // since this is a dummy volume it is based on the position of the base plate coordinate system + // width - u + // length - v + // thickness - w + Hep3Vector ball_pos_base = ball_pos_base_plate; + Hep3Vector vee_pos_base = vee_pos_base_plate; + Hep3Vector flat_pos_base = flat_pos_base_plate; + CoordSysDef base_coord = new CoordSysDef(ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate); + Transform3D trans_base_to_tracking = getTransformation(base_coord); +
String volName = "base";
- Box box = new Box(volName + "Box", this.base_width, this.base_height , this.base_length);
+ Box box = new Box(volName + "Box", base_width, base_length , base_height);
lcdd.add(box); Volume baseVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
- - // create the coordinate system of the base plate - CoordSysDef base_plate_coord = new CoordSysDef(ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate); - Transform3D trans_base_plate_to_tracking = getTransformation(base_plate_coord); - - -
if(_debug) {
- print(String.format("ball_pos_base_plate %s", ball_pos_base_plate.toString())); - print(String.format("vee_pos_base_plate %s", vee_pos_base_plate.toString())); - print(String.format("flat_pos_base_plate %s", flat_pos_base_plate.toString())); - print(String.format("base_plate_coord:\n%s", base_plate_coord.toString()));
+ print(String.format("ball_pos_base %s", ball_pos_base.toString())); + print(String.format("vee_pos_base %s", vee_pos_base.toString())); + print(String.format("flat_pos_base %s", flat_pos_base.toString())); + print(String.format("base_coord:\n%s", base_coord.toString()));
}
+
+ // Find distance to center in the local coordinate system + Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, base_height/2.0 - base_plate_thickness);
- - // Find distance to center in the local coordinate system - Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, base_height/2.0 - this.base_plate_thickness); - Hep3Vector box_center_base = trans_base_plate_to_tracking.transformed(box_center_base_local);
+ //translate to the mother coordinate system + Hep3Vector box_center_base = trans_base_to_tracking.transformed(box_center_base_local);
print(String.format("box_center_base_local %s", box_center_base_local.toString())); print(String.format("box_center_base %s", box_center_base.toString()));
-
+ // Create the LCDD position
Position pos = new Position(volName + "_position",box_center_base.x(), box_center_base.y(), box_center_base.z());
- //Find LCDD rotation angles from coordinate system unit vectors - Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); //getLCDDRotation(support_plate_coord);
+ + //Find LCDD Euler rotation angles from coordinate system unit vectors + Hep3Vector lcdd_rot_angles = getEulerAngles(base_coord.v, base_coord.w, new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()); lcdd.add(pos); lcdd.add(rot);
+ // Create the physical volume
PhysVol basePV = new PhysVol(baseVolume, trackingWrap.vol, pos, rot);
-
+ + // Crate the wrapper for this volume
VolWrapper baseWrap = new VolWrapper(); baseWrap.vol = baseVolume; baseWrap.name = volName; baseWrap.pos_vol = pos; baseWrap.rot_vol = rot;
- baseWrap.coord = base_plate_coord;
+ baseWrap.coord = base_coord; + baseWrap.mother = trackingWrap; + baseWrap.center = box_center_base_local;
-
// create the base plate inside the support box
- makeBasePlate(baseWrap, ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate, lcdd, sens );
+ + // need to create new local survey points since it's w.r.t. to the base volume
+ if(_debug) { + print(String.format("ball_pos_base_plate %s", ball_pos_base_plate.toString())); + print(String.format("vee_pos_base_plate %s", vee_pos_base_plate.toString())); + print(String.format("flat_pos_base_plate %s", flat_pos_base_plate.toString())); + } + + Hep3Vector ball_pos_base_plate_2 = new BasicHep3Vector(0,0,0); + Hep3Vector vee_pos_base_plate_2 = new BasicHep3Vector(base_plate_width,ball_pos_base_plate_2.y(),ball_pos_base_plate_2.z()); + Hep3Vector flat_pos_base_plate_2 = new BasicHep3Vector(ball_pos_base_plate_2.x(),base_plate_length,ball_pos_base_plate_2.z()); + + if(_debug) { + print(String.format("ball_pos_base_plate_2 %s", ball_pos_base_plate_2.toString())); + print(String.format("vee_pos_base_plate_2 %s", vee_pos_base_plate_2.toString())); + print(String.format("flat_pos_base_plate_2 %s", flat_pos_base_plate_2.toString())); + } + + + + makeBasePlate(baseWrap, ball_pos_base_plate_2, vee_pos_base_plate_2, flat_pos_base_plate_2, lcdd, sens ); +
if(_debug) { print("Make c-support positions on base plate for bottom");
@@ -306,7 +477,7 @@
print(String.format("flat_pos_csup %s", flat_pos_csup.toString())); }
- makeSupport("bottom", baseWrap, ball_pos_csup, vee_pos_csup, flat_pos_csup, lcdd, sens );
+ //makeSupport("bottom", baseWrap, ball_pos_csup, vee_pos_csup, flat_pos_csup, lcdd, sens );
//baseVolume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis"));
@@ -356,6 +527,109 @@
+ + private void makeBasePlate(VolWrapper baseWrap, + Hep3Vector ball_pos_base_plate, + Hep3Vector vee_pos_base_plate, + Hep3Vector flat_pos_base_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException { + + if(_debug) { + print("--- makeBasePlate----"); + } + + + + + + + // create the coordinate system + // width - u + // length - v + // thickness - w + // create the coordinate system + CoordSysDef base_plate_coord = new CoordSysDef(ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate); + Transform3D trans_base_plate_to_base = getTransformation(base_plate_coord); + + String volName = "baseplate"; + Box box = new Box(volName + "Box", base_plate_width,base_plate_length, base_plate_thickness); + lcdd.add(box); + Volume basePlateVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum")); + + + if(_debug) { + print(String.format("ball_pos_base_plate %s", ball_pos_base_plate.toString())); + print(String.format("vee_pos_base_plate %s", vee_pos_base_plate.toString())); + print(String.format("flat_pos_base_plate %s", flat_pos_base_plate.toString())); + print(String.format("base_plate_coord:\n%s", base_plate_coord.toString())); + } + + + + // Find distance to center in the local coordinate system + Hep3Vector box_center_base_plate_local = new BasicHep3Vector(base_plate_width/2.0, base_plate_length/2.0, -base_plate_thickness/2.0); + + //translate to the mother coordinate system + Hep3Vector box_center_base_plate = trans_base_plate_to_base.transformed(box_center_base_plate_local); + + // find the displacement from the rotation around an arbitrary point in local coordinates + //Hep3Vector box_center_module_coord_rot = getRotationDisplacement(ball_pos_halfmod, box_center_module_coord, lcdd_rot_angles); + + // find the position of the center in the mother coord + Hep3Vector box_center = VecOp.sub(box_center_base_plate, baseWrap.center); + + //Hep3Vector box_center_sub = VecOp.sub(box_center_module_coord_rot, moduleWrap.center); + //Hep3Vector box_center = transModuleToSupportCoord.rotated(box_center_sub); + + // fix the rotation + //Hep3Vector lcdd_rot_angles_support = transModuleToSupportCoord.rotated(lcdd_rot_angles); + + + + print(String.format("box_center_base_plate_local %s", box_center_base_plate_local.toString())); + print(String.format("box_center_base_plate %s", box_center_base_plate.toString())); + print(String.format("baseWrap.center %s", baseWrap.center.toString())); + print(String.format("box_center %s", box_center.toString())); + + // Create the LCDD position + Position pos = new Position(volName + "_position",box_center.x(), box_center.y(), box_center.z()); + //Position pos = new Position(volName + "_position",box_center_base_plate.x(), box_center_base_plate.y(), box_center_base_plate.z()); + //Position pos = new Position(volName + "_position",0,0,0); + + //Find LCDD Euler rotation angles from coordinate system unit vectors + Hep3Vector lcdd_rot_angles = getEulerAngles(new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0), base_plate_coord.u, base_plate_coord.v); + //Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); + Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()); + lcdd.add(pos); + lcdd.add(rot); + + // Create the physical volume + PhysVol basePlatePV = new PhysVol(basePlateVolume, baseWrap.vol, pos, rot); + + // Crate the wrapper for this volume + VolWrapper basePlateWrap = new VolWrapper(); + basePlateWrap.mother = baseWrap; + basePlateWrap.vol = basePlateVolume; + basePlateWrap.name = volName; + basePlateWrap.coord = base_plate_coord; + basePlateWrap.pos_vol = pos; + basePlateWrap.rot_vol = rot; + baseWrap.daughters.add(basePlateWrap); + + + + // add volume to lcdd + basePlateVolume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis")); + lcdd.add(basePlateVolume); + + + + + } + + + + +
private void makeSupport(String name, VolWrapper baseWrap, Hep3Vector ball_pos_csup, Hep3Vector vee_pos_csup, Hep3Vector flat_pos_csup, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
@@ -703,74 +977,8 @@
- private void makeBasePlate(VolWrapper baseWrap, - Hep3Vector ball_pos_base_plate, - Hep3Vector vee_pos_base_plate, - Hep3Vector flat_pos_base_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException { - - if(_debug) { - print("--- makeBasePlate----"); - } - // create the coordinate system - CoordSysDef base_plate_coord = new CoordSysDef(ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate); - Transform3D trans_base_plate_to_base = getTransformation(base_plate_coord); - - - if(_debug) { - print(String.format("ball_pos_base_plate %s", ball_pos_base_plate.toString())); - print(String.format("vee_pos_base_plate %s", vee_pos_base_plate.toString())); - print(String.format("flat_pos_base_plate %s", flat_pos_base_plate.toString())); - print(String.format("base_plate_coord:\n%s", base_plate_coord.toString())); - } - - - Hep3Vector box_dim_local = new BasicHep3Vector(base_plate_width,base_plate_length,this.base_plate_thickness); - Hep3Vector box_dim = trans_base_plate_to_base.rotated(box_dim_local); - - if(_debug) { - print(String.format("box_dim_local %s", box_dim_local.toString())); - print(String.format("box_dim %s", box_dim.toString())); - } - - String volName = "baseplate"; - Box box = new Box(volName + "Box", box_dim.x(), box_dim.y(), box_dim.z()); - lcdd.add(box); - Volume basePlateVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Aluminum")); - - - // Find distance to center in the local coordinate system - Hep3Vector box_center_base_plate_local = new BasicHep3Vector(base_plate_width/2.0, base_plate_length/2.0, -1.0 * base_plate_thickness/2.0); - Hep3Vector box_center_base_plate = trans_base_plate_to_base.transformed(box_center_base_plate_local); - - print(String.format("box_center_base_plate_local %s", box_center_base_plate_local.toString())); - print(String.format("box_center_base_plate %s", box_center_base_plate.toString())); - - - Position pos = new Position(volName + "_position",box_center_base_plate.x(), box_center_base_plate.y(), box_center_base_plate.z()); - Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); //getLCDDRotation(support_plate_coord); - Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z()); - lcdd.add(pos); - lcdd.add(rot); - PhysVol basePlatePV = new PhysVol(basePlateVolume, baseWrap.vol, pos, rot); - // add volume to lcdd - - basePlateVolume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis")); - - lcdd.add(basePlateVolume); - - VolWrapper basePlateWrap = new VolWrapper(); - basePlateWrap.mother = baseWrap; - basePlateWrap.vol = basePlateVolume; - basePlateWrap.name = volName; - basePlateWrap.pos_vol = pos; - basePlateWrap.rot_vol = rot; - baseWrap.daughters.add(basePlateWrap); - - - - } -
+
private void makeModule(String name, VolWrapper supportWrap, Hep3Vector ball_pos_mod, Hep3Vector vee_pos_mod, Hep3Vector flat_pos_mod, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
@@ -1770,7 +1978,86 @@
}
+ private Hep3Vector getEulerAngles(Hep3Vector u, Hep3Vector v, Hep3Vector u_prime, Hep3Vector v_prime) { + // Convert to correct API + org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u.v()); + org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v.v()); + org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u_prime.v()); + org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v_prime.v()); + //Get the generic rotation + org.apache.commons.math3.geometry.euclidean.threed.Rotation rot = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(u_3D,v_3D,u_prime_3D,v_prime_3D); + //Get the angles + double res[] = rot.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + Hep3Vector euler = new BasicHep3Vector(res); + print("u " + u_3D.toString() + " v " + v_3D.toString() + " u' " + u_prime_3D.toString() + " v' " + v_prime_3D.toString()); + print("rot matrix:"); + double[][] mat = rot.getMatrix(); + for(int r=0;r<3;++r) { + String row = ""; + for(int c=0;c<3;++c) { + row += String.format(" %f",mat[r][c]); + } + System.out.println(row); + } + print("XYZ angles " + euler.toString()); + //euler = VecOp.mult(-1.0, euler); + print("XYZ angles " + euler.toString() + " (passive)"); + + + + /* + if(true) { + print("test2"); + org.apache.commons.math3.geometry.euclidean.threed.Rotation rot2 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(v_3D,v_prime_3D); + double res2[] = rot2.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + Hep3Vector euler2 = new BasicHep3Vector(res2); + print("u " + u_3D.toString() + " v " + v_3D.toString() + " u' " + u_prime_3D.toString() + " v' " + v_prime_3D.toString()); + print("rot matrix:"); + double[][] mat2 = rot2.getMatrix(); + for(int r=0;r<3;++r) { + String row = ""; + for(int c=0;c<3;++c) { + row += String.format(" %f",mat2[r][c]); + } + System.out.println(row); + } + print("XYZ angles " + euler2.toString()); + euler2 = VecOp.mult(-1.0, euler2); + print("XYZ angles " + euler2.toString() + " (passive)"); + + + print("test3"); + //org.apache.commons.math3.geometry.euclidean.threed.Rotation rot3 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,0,0,0); + org.apache.commons.math3.geometry.euclidean.threed.Rotation rot3 = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,-3.1416,0,-3.1416); + double res3[] = rot3.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ); + Hep3Vector euler3 = new BasicHep3Vector(res3); + print("rot matrix:"); + double[][] mat3 = rot3.getMatrix(); + for(int r=0;r<3;++r) { + String row = ""; + for(int c=0;c<3;++c) { + row += String.format(" %f",mat3[r][c]); + } + System.out.println(row); + } + print("XYZ angles " + euler3.toString()); + euler3 = VecOp.mult(-1.0, euler3); + print("XYZ angles " + euler3.toString() + " (passive)"); + + + + } +*/
+ + + + + return euler; + } + + +
private static class CoordSysDef { private Hep3Vector origin; private Hep3Vector u;
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1