4 added + 4 removed, total 8 files
GeomConverter/src/org/lcsim/detector
diff -N CoordinateTransformation3D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CoordinateTransformation3D.java 24 Feb 2007 03:19:24 -0000 1.1
@@ -0,0 +1,100 @@
+/*
+ * CoordinateTransformation3D.java
+ */
+
+package org.lcsim.detector;
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.VecOp;
+
+/**
+ *
+ * @author tknelson
+ */
+public class CoordinateTransformation3D
+{
+
+ // Fields
+ Hep3Vector _translation = new BasicHep3Vector(0.0,0.0,0.0);
+ Rotation3D _rotation = new Rotation3D();
+
+ /**
+ * Creates a new instance of CoordinateTransformation3D
+ */
+ public CoordinateTransformation3D()
+ {
+ }
+
+ public CoordinateTransformation3D(Rotation3D rotation)
+ {
+ this._rotation = rotation;
+ }
+
+ public CoordinateTransformation3D(Hep3Vector translation)
+ {
+ this._translation = translation;
+ }
+
+ public CoordinateTransformation3D(Hep3Vector translation, Rotation3D rotation)
+ {
+ _translation = translation;
+ _rotation = rotation;
+ }
+
+ // Access to translation and rotation
+ public Hep3Vector getTranslation()
+ {
+ return _translation;
+ }
+
+ public Rotation3D getRotation()
+ {
+ return _rotation;
+ }
+
+ // Transformations
+ public Hep3Vector transform(Hep3Vector coordinates)
+ {
+ translate(coordinates);
+ rotate(coordinates);
+ return coordinates;
+ }
+
+ public Hep3Vector translate(Hep3Vector coordinates)
+ {
+ return VecOp.add(coordinates,_translation);
+ }
+
+ public Hep3Vector rotate(Hep3Vector coordinates)
+ {
+ //return VecOp.mult(_rotation,coordinates);
+ return VecOp.mult(_rotation.getMatrix(),coordinates);
+ }
+
+ // Invert the transformation
+ public void invert()
+ {
+ _translation = VecOp.mult(-1.0,VecOp.mult(_rotation.getMatrix(),_translation));
+ _rotation.invert(); // Need to assure that transpose is used
+ }
+
+ // FIXME: Talk to Tony about supporting this pattern
+
+// public CoordinateTransformation3D inverse()
+// {
+// CoordinateTransformation3D transform = new CoordinateTransformation3D(
+// VecOp.mult(-1.0,VecOp.mult(_rotation,_translation)),
+// _rotation.inverse()); // FIXME: Need to assure that transpose is used
+// return transform;
+// }
+
+ // Static functions
+ public static CoordinateTransformation3D mult(CoordinateTransformation3D transformation1, CoordinateTransformation3D transformation2)
+ {
+ Rotation3D rotation = new Rotation3D(VecOp.mult(transformation1.getRotation().getMatrix(),transformation2.getRotation().getMatrix()));
+ Hep3Vector translation = VecOp.add(VecOp.mult(transformation1.getRotation().getMatrix(),transformation2.getTranslation()),transformation1.getTranslation());
+ return new CoordinateTransformation3D(translation,rotation);
+ }
+
+}
GeomConverter/src/org/lcsim/detector
diff -N Rotation3D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Rotation3D.java 24 Feb 2007 03:19:24 -0000 1.1
@@ -0,0 +1,220 @@
+/*
+ * Hep3Rotation.java
+ */
+
+//package org.lcsim.contrib.subdetector.tracker.silicon;
+
+package org.lcsim.detector;
+
+import hep.physics.vec.BasicHep3Matrix;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Matrix;
+import hep.physics.vec.Hep3Matrix;
+import hep.physics.vec.VecOp;
+
+import java.io.PrintStream;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Rotation3D
+{
+ private BasicHep3Matrix matrix = BasicHep3Matrix.identity();
+
+ // Fields
+ //=======
+ /**
+ * Create a new Hep3Rotation containing the identify matrix.
+ */
+ public Rotation3D()
+ {}
+
+ /**
+ * Create a new Hep3Rotation from a 3x3 matrix.
+ * @param matrix
+ */
+ public Rotation3D(BasicHep3Matrix matrix)
+ {
+ setMatrix(matrix);
+ }
+
+ public Rotation3D(Hep3Matrix matrix)
+ {
+ setMatrix((BasicHep3Matrix)matrix);
+ }
+
+ public BasicHep3Matrix getMatrix()
+ {
+ return this.matrix;
+ }
+
+ public void setMatrix(BasicHep3Matrix matrix)
+ {
+ this.matrix = matrix;
+ }
+
+ /**
+ * Transform rotation using Tait-Bryan convention.
+ * @param alpha
+ * @param beta
+ * @param gamma
+ */
+ public void setTaitBryan(double alpha, double beta, double gamma)
+ {
+ matrix = passiveTaitBryan(alpha,beta,gamma);
+ }
+
+ public void setPassiveEuler(double phi, double theta, double psi)
+ {
+ matrix.setPassiveEuler(phi,theta,psi);
+ }
+
+ public static BasicHep3Matrix passiveEuler(double phi, double theta, double psi)
+ {
+ BasicHep3Matrix matrix = new BasicHep3Matrix();
+ matrix.setPassiveEuler(phi,theta,psi);
+ return matrix;
+ }
+
+ // Static Methods
+ //===============
+ public static BasicHep3Matrix passiveTaitBryan(double alpha, double beta, double gamma)
+ {
+ return (BasicHep3Matrix)VecOp.mult(passiveZRotation(gamma),VecOp.mult(passiveYRotation(beta),passiveXRotation(alpha)));
+ }
+
+ public static BasicHep3Matrix passiveXRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ BasicHep3Matrix rotation = BasicHep3Matrix.identity();
+ rotation.setElement(1,1,cos);
+ rotation.setElement(1,2,sin);
+ rotation.setElement(2,1,-sin);
+ rotation.setElement(2,2,cos);
+ return rotation;
+ }
+
+ public static BasicHep3Matrix passiveYRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ BasicHep3Matrix rotation = BasicHep3Matrix.identity();
+ rotation.setElement(0,0,cos);
+ rotation.setElement(0,2,sin);
+ rotation.setElement(2,0,-sin);
+ rotation.setElement(2,2,cos);
+ return rotation;
+ }
+
+ public static BasicHep3Matrix passiveZRotation(double angle)
+ {
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
+ BasicHep3Matrix rotation = BasicHep3Matrix.identity();
+ rotation.setElement(0,0,cos);
+ rotation.setElement(0,1,sin);
+ rotation.setElement(1,0,-sin);
+ rotation.setElement(1,1,cos);
+ return rotation;
+ }
+
+ public void invert()
+ {
+ matrix.transpose();
+ }
+
+ public double xx()
+ {
+ return matrix.e(0,0);
+ }
+
+ public double xy()
+ {
+ return matrix.e(0,1);
+ }
+
+ public double xz()
+ {
+ return matrix.e(0,2);
+ }
+
+ public double yx()
+ {
+ return matrix.e(1,0);
+ }
+
+ public double yy()
+ {
+ return matrix.e(1,1);
+ }
+
+ public double yz()
+ {
+ return matrix.e(1,2);
+ }
+
+ public double zx()
+ {
+ return matrix.e(2,0);
+ }
+
+ public double zy()
+ {
+ return matrix.e(2,1);
+ }
+
+ public double zz()
+ {
+ return matrix.e(2,2);
+ }
+
+ Hep3Vector colX()
+ {
+ return new BasicHep3Vector(matrix.e(0,0),matrix.e(1,0),matrix.e(2,0));
+ }
+
+ Hep3Vector colY()
+ {
+ return new BasicHep3Vector(matrix.e(0,1),matrix.e(1,1),matrix.e(2,1));
+ }
+
+ Hep3Vector colZ()
+ {
+ return new BasicHep3Vector(matrix.e(0,2),matrix.e(1,2),matrix.e(2,2));
+ }
+
+ Hep3Vector rowX()
+ {
+ return new BasicHep3Vector(matrix.e(0,0),matrix.e(0,1),matrix.e(0,2));
+ }
+
+ Hep3Vector rowY()
+ {
+ return new BasicHep3Vector(matrix.e(1,0),matrix.e(1,1),matrix.e(1,2));
+ }
+
+ Hep3Vector rowZ()
+ {
+ return new BasicHep3Vector(matrix.e(2,0),matrix.e(2,1),matrix.e(2,2));
+ }
+
+ public void printOut(PrintStream ps)
+ {
+ ps.print("[");
+ ps.println();
+
+ BasicHep3Matrix m = getMatrix();
+
+ for (int i=0; i<3; i++)
+ {
+ ps.printf("%.4f %.4f %.4f", m.e(i,0), m.e(i,1), m.e(i,2));
+ ps.println();
+ }
+
+ ps.print("]");
+ ps.println('\n');
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/kernel
diff -N CoordinateTransformation3D.java
--- CoordinateTransformation3D.java 23 Feb 2007 21:44:37 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-/*
- * CoordinateTransformation3D.java
- */
-
-package org.lcsim.detector.kernel;
-
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.VecOp;
-
-/**
- *
- * @author tknelson
- */
-public class CoordinateTransformation3D
-{
-
- // Fields
- Hep3Vector _translation = new BasicHep3Vector(0.0,0.0,0.0);
- Rotation3D _rotation = new Rotation3D();
-
- /**
- * Creates a new instance of CoordinateTransformation3D
- */
- public CoordinateTransformation3D()
- {
- }
-
- public CoordinateTransformation3D(Rotation3D rotation)
- {
- this._rotation = rotation;
- }
-
- public CoordinateTransformation3D(Hep3Vector translation)
- {
- this._translation = translation;
- }
-
- public CoordinateTransformation3D(Hep3Vector translation, Rotation3D rotation)
- {
- _translation = translation;
- _rotation = rotation;
- }
-
- // Access to translation and rotation
- public Hep3Vector getTranslation()
- {
- return _translation;
- }
-
- public Rotation3D getRotation()
- {
- return _rotation;
- }
-
- // Transformations
- public Hep3Vector transform(Hep3Vector coordinates)
- {
- translate(coordinates);
- rotate(coordinates);
- return coordinates;
- }
-
- public Hep3Vector translate(Hep3Vector coordinates)
- {
- return VecOp.add(coordinates,_translation);
- }
-
- public Hep3Vector rotate(Hep3Vector coordinates)
- {
- //return VecOp.mult(_rotation,coordinates);
- return VecOp.mult(_rotation.getMatrix(),coordinates);
- }
-
- // Invert the transformation
- public void invert()
- {
- _translation = VecOp.mult(-1.0,VecOp.mult(_rotation.getMatrix(),_translation));
- _rotation.invert(); // Need to assure that transpose is used
- }
-
- // FIXME: Talk to Tony about supporting this pattern
-
-// public CoordinateTransformation3D inverse()
-// {
-// CoordinateTransformation3D transform = new CoordinateTransformation3D(
-// VecOp.mult(-1.0,VecOp.mult(_rotation,_translation)),
-// _rotation.inverse()); // FIXME: Need to assure that transpose is used
-// return transform;
-// }
-
- // Static functions
- public static CoordinateTransformation3D mult(CoordinateTransformation3D transformation1, CoordinateTransformation3D transformation2)
- {
- Rotation3D rotation = new Rotation3D(VecOp.mult(transformation1.getRotation().getMatrix(),transformation2.getRotation().getMatrix()));
- Hep3Vector translation = VecOp.add(VecOp.mult(transformation1.getRotation().getMatrix(),transformation2.getTranslation()),transformation1.getTranslation());
- return new CoordinateTransformation3D(translation,rotation);
- }
-
-}
GeomConverter/src/org/lcsim/detector/kernel
diff -N Rotation3D.java
--- Rotation3D.java 24 Feb 2007 00:30:06 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,220 +0,0 @@
-/*
- * Hep3Rotation.java
- */
-
-//package org.lcsim.contrib.subdetector.tracker.silicon;
-
-package org.lcsim.detector.kernel;
-
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.Hep3Matrix;
-import hep.physics.vec.VecOp;
-
-import java.io.PrintStream;
-
-/**
- *
- * @author tknelson
- */
-public class Rotation3D
-{
- private BasicHep3Matrix matrix = BasicHep3Matrix.identity();
-
- // Fields
- //=======
- /**
- * Create a new Hep3Rotation containing the identify matrix.
- */
- public Rotation3D()
- {}
-
- /**
- * Create a new Hep3Rotation from a 3x3 matrix.
- * @param matrix
- */
- public Rotation3D(BasicHep3Matrix matrix)
- {
- setMatrix(matrix);
- }
-
- public Rotation3D(Hep3Matrix matrix)
- {
- setMatrix((BasicHep3Matrix)matrix);
- }
-
- public BasicHep3Matrix getMatrix()
- {
- return this.matrix;
- }
-
- public void setMatrix(BasicHep3Matrix matrix)
- {
- this.matrix = matrix;
- }
-
- /**
- * Transform rotation using Tait-Bryan convention.
- * @param alpha
- * @param beta
- * @param gamma
- */
- public void setTaitBryan(double alpha, double beta, double gamma)
- {
- matrix = passiveTaitBryan(alpha,beta,gamma);
- }
-
- public void setPassiveEuler(double phi, double theta, double psi)
- {
- matrix.setPassiveEuler(phi,theta,psi);
- }
-
- public static BasicHep3Matrix passiveEuler(double phi, double theta, double psi)
- {
- BasicHep3Matrix matrix = new BasicHep3Matrix();
- matrix.setPassiveEuler(phi,theta,psi);
- return matrix;
- }
-
- // Static Methods
- //===============
- public static BasicHep3Matrix passiveTaitBryan(double alpha, double beta, double gamma)
- {
- return (BasicHep3Matrix)VecOp.mult(passiveZRotation(gamma),VecOp.mult(passiveYRotation(beta),passiveXRotation(alpha)));
- }
-
- public static BasicHep3Matrix passiveXRotation(double angle)
- {
- double sin = Math.sin(angle);
- double cos = Math.cos(angle);
- BasicHep3Matrix rotation = BasicHep3Matrix.identity();
- rotation.setElement(1,1,cos);
- rotation.setElement(1,2,sin);
- rotation.setElement(2,1,-sin);
- rotation.setElement(2,2,cos);
- return rotation;
- }
-
- public static BasicHep3Matrix passiveYRotation(double angle)
- {
- double sin = Math.sin(angle);
- double cos = Math.cos(angle);
- BasicHep3Matrix rotation = BasicHep3Matrix.identity();
- rotation.setElement(0,0,cos);
- rotation.setElement(0,2,sin);
- rotation.setElement(2,0,-sin);
- rotation.setElement(2,2,cos);
- return rotation;
- }
-
- public static BasicHep3Matrix passiveZRotation(double angle)
- {
- double sin = Math.sin(angle);
- double cos = Math.cos(angle);
- BasicHep3Matrix rotation = BasicHep3Matrix.identity();
- rotation.setElement(0,0,cos);
- rotation.setElement(0,1,sin);
- rotation.setElement(1,0,-sin);
- rotation.setElement(1,1,cos);
- return rotation;
- }
-
- public void invert()
- {
- matrix.transpose();
- }
-
- public double xx()
- {
- return matrix.e(0,0);
- }
-
- public double xy()
- {
- return matrix.e(0,1);
- }
-
- public double xz()
- {
- return matrix.e(0,2);
- }
-
- public double yx()
- {
- return matrix.e(1,0);
- }
-
- public double yy()
- {
- return matrix.e(1,1);
- }
-
- public double yz()
- {
- return matrix.e(1,2);
- }
-
- public double zx()
- {
- return matrix.e(2,0);
- }
-
- public double zy()
- {
- return matrix.e(2,1);
- }
-
- public double zz()
- {
- return matrix.e(2,2);
- }
-
- Hep3Vector colX()
- {
- return new BasicHep3Vector(matrix.e(0,0),matrix.e(1,0),matrix.e(2,0));
- }
-
- Hep3Vector colY()
- {
- return new BasicHep3Vector(matrix.e(0,1),matrix.e(1,1),matrix.e(2,1));
- }
-
- Hep3Vector colZ()
- {
- return new BasicHep3Vector(matrix.e(0,2),matrix.e(1,2),matrix.e(2,2));
- }
-
- Hep3Vector rowX()
- {
- return new BasicHep3Vector(matrix.e(0,0),matrix.e(0,1),matrix.e(0,2));
- }
-
- Hep3Vector rowY()
- {
- return new BasicHep3Vector(matrix.e(1,0),matrix.e(1,1),matrix.e(1,2));
- }
-
- Hep3Vector rowZ()
- {
- return new BasicHep3Vector(matrix.e(2,0),matrix.e(2,1),matrix.e(2,2));
- }
-
- public void printOut(PrintStream ps)
- {
- ps.print("[");
- ps.println();
-
- BasicHep3Matrix m = getMatrix();
-
- for (int i=0; i<3; i++)
- {
- ps.printf("%.4f %.4f %.4f", m.e(i,0), m.e(i,1), m.e(i,2));
- ps.println();
- }
-
- ps.print("]");
- ps.println('\n');
- }
-}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector
diff -N CoordinateTransformation3DTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CoordinateTransformation3DTest.java 24 Feb 2007 03:19:24 -0000 1.1
@@ -0,0 +1,141 @@
+package org.lcsim.detector;
+
+import org.lcsim.detector.CoordinateTransformation3D;
+import org.lcsim.detector.Rotation3D;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class CoordinateTransformation3DTest extends TestCase
+{
+ public CoordinateTransformation3DTest(String name)
+ {
+ super(name);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new TestSuite(CoordinateTransformation3DTest.class);
+ }
+
+ protected void setUp() throws Exception
+ {}
+
+ public void testIdentityTransformation()
+ {
+ System.out.println("CoordinateTransformation3DTest.testIdentityTransformation");
+
+ CoordinateTransformation3D transform = new CoordinateTransformation3D();
+ CoordinateTransformation3D point = new CoordinateTransformation3D(new BasicHep3Vector(1.0,0.0,0.0), new Rotation3D());
+ CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
+
+ Hep3Vector translation = result.getTranslation();
+ assert(translation.x() == 1.0);
+ assert(translation.y() == 0);
+ assert(translation.y() == 0);
+
+ Rotation3D rotation = result.getRotation();
+ assert(rotation.getMatrix().trace() == 3.0);
+ }
+
+ public void testSimpleTranslationX()
+ {
+ System.out.println("CoordinateTransformation3DTest.testSimpleTranslationX");
+
+ CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(1.0,0.0,0.0));
+ CoordinateTransformation3D point = new CoordinateTransformation3D();
+ CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
+ Hep3Vector translation = result.getTranslation();
+ assert(translation.x() == 1.0);
+ assert(translation.y() == 0.0);
+ assert(translation.z() == 0.0);
+ }
+
+ public void testSimpleTranslationY()
+ {
+ System.out.println("CoordinateTransformation3DTest.testSimpleTranslationY");
+
+ CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(0.0,1.0,0.0));
+ CoordinateTransformation3D point = new CoordinateTransformation3D();
+ CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
+ Hep3Vector translation = result.getTranslation();
+ assert(translation.x() == 0.0);
+ assert(translation.y() == 1.0);
+ assert(translation.z() == 0.0);
+ }
+
+ public void testSimpleTranslationZ()
+ {
+ System.out.println("CoordinateTransformation3DTest.testSimpleTranslationZ");
+
+ CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(0.0,0.0,1.0));
+ CoordinateTransformation3D point = new CoordinateTransformation3D();
+ CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
+ Hep3Vector translation = result.getTranslation();
+ assert(translation.x() == 0.0);
+ assert(translation.y() == 0.0);
+ assert(translation.z() == 1.0);
+ }
+
+ public void testSimpleTranslationXYZ()
+ {
+ System.out.println("CoordinateTransformation3DTest.testSimpleTranslationXYZ");
+
+ CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(1.0,1.0,1.0));
+ CoordinateTransformation3D point = new CoordinateTransformation3D();
+ CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
+ Hep3Vector translation = result.getTranslation();
+ assert(translation.x() == 1.0);
+ assert(translation.y() == 1.0);
+ assert(translation.z() == 1.0);
+ }
+
+ public void testSimpleRotationX()
+ {
+ System.out.println("CoordinateTransformation3DTest.testSimpleRotationX");
+
+ Rotation3D rotateX = new Rotation3D();
+ rotateX.setTaitBryan(Math.PI / 4, 0, 0);
+ CoordinateTransformation3D transform = new CoordinateTransformation3D(rotateX);
+ //CoordinateTransformation3D point = new CoordinateTransformation3D();
+ Hep3Vector point = new BasicHep3Vector(1.0,0.0,0.0);
+ Hep3Vector result = transform.rotate(point);
+ System.out.println("Transform");
+ transform.getRotation().printOut(System.out);
+ System.out.printf("new point = ( %.4f %.4f %.4f )\n",result.x(),result.y(),result.z());
+ //CoordinateTransformation3D.mult(point, transform);
+ //Hep3Rotation rotation = result.getRotation();
+
+ //System.out.println("transformation");
+ //rotateX.printOut(System.out);
+ //System.out.println();
+ //System.out.println("transformed point");
+ //rotation.printOut(System.out);
+
+ //assertStrictEquals(rotation, rotateX);
+
+ }
+
+ public void testRotationIdentity()
+ {
+ System.out.println("CoordinateTransformation3DTest.testRotationIdentity");
+ Rotation3D rotation = new Rotation3D();
+ System.out.println("This should be the identity matrix.");
+ rotation.printOut(System.out);
+ }
+
+ private static final void assertStrictEquals(Rotation3D rotate1, Rotation3D rotate2)
+ {
+ assert(rotate1.xx() == rotate2.xx());
+ assert(rotate1.xy() == rotate2.xy());
+ assert(rotate1.xz() == rotate2.xz());
+ assert(rotate1.yx() == rotate2.yx());
+ assert(rotate1.yy() == rotate2.yy());
+ assert(rotate1.yz() == rotate2.yz());
+ assert(rotate1.zx() == rotate2.zx());
+ assert(rotate1.zy() == rotate2.zy());
+ assert(rotate1.zz() == rotate2.zz());
+ }
+}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector
diff -N Rotation3DTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Rotation3DTest.java 24 Feb 2007 03:19:24 -0000 1.1
@@ -0,0 +1,78 @@
+package org.lcsim.detector;
+
+import org.lcsim.detector.Rotation3D;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class Rotation3DTest extends TestCase
+{
+ public Rotation3DTest(String name)
+ {
+ super(name);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new TestSuite(Rotation3DTest.class);
+ }
+
+ protected void setUp() throws Exception
+ {}
+
+ public void testIdentityIsDefault()
+ {
+ Rotation3D rotation = new Rotation3D();
+ assert(rotation.getMatrix().trace() == 3.0);
+ }
+
+ public void testSimpleRotationX()
+ {
+ Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
+ Rotation3D rotation = new Rotation3D();
+ rotation.setTaitBryan(Math.PI / 2, 0, 0);
+ Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
+ System.out.println("90 degree X rotation");
+ rotation.printOut(System.out);
+ System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
+ System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+ rotation.invert();
+ result = VecOp.mult(rotation.getMatrix(),result);
+ System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+
+ }
+
+ public void testSimpleRotationY()
+ {
+ Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
+ Rotation3D rotation = new Rotation3D();
+ rotation.setTaitBryan(0, Math.PI / 2, 0);
+ Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
+ System.out.println("90 degree Y rotation");
+ rotation.printOut(System.out);
+ System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
+ System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+ rotation.invert();
+ result = VecOp.mult(rotation.getMatrix(),result);
+ System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+ }
+
+ public void testSimpleRotationZ()
+ {
+ Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
+ Rotation3D rotation = new Rotation3D();
+ rotation.setTaitBryan(0, 0, Math.PI / 2);
+ Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
+ System.out.println("90 degree Z rotation");
+ rotation.printOut(System.out);
+ System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
+ System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+ rotation.invert();
+ result = VecOp.mult(rotation.getMatrix(),result);
+ System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
+ }
+
+}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector/kernel
diff -N CoordinateTransformation3DTest.java
--- CoordinateTransformation3DTest.java 23 Feb 2007 21:47:48 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,138 +0,0 @@
-package org.lcsim.detector.kernel;
-
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class CoordinateTransformation3DTest extends TestCase
-{
- public CoordinateTransformation3DTest(String name)
- {
- super(name);
- }
-
- public static junit.framework.Test suite()
- {
- return new TestSuite(CoordinateTransformation3DTest.class);
- }
-
- protected void setUp() throws Exception
- {}
-
- public void testIdentityTransformation()
- {
- System.out.println("CoordinateTransformation3DTest.testIdentityTransformation");
-
- CoordinateTransformation3D transform = new CoordinateTransformation3D();
- CoordinateTransformation3D point = new CoordinateTransformation3D(new BasicHep3Vector(1.0,0.0,0.0), new Rotation3D());
- CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
-
- Hep3Vector translation = result.getTranslation();
- assert(translation.x() == 1.0);
- assert(translation.y() == 0);
- assert(translation.y() == 0);
-
- Rotation3D rotation = result.getRotation();
- assert(rotation.getMatrix().trace() == 3.0);
- }
-
- public void testSimpleTranslationX()
- {
- System.out.println("CoordinateTransformation3DTest.testSimpleTranslationX");
-
- CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(1.0,0.0,0.0));
- CoordinateTransformation3D point = new CoordinateTransformation3D();
- CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
- Hep3Vector translation = result.getTranslation();
- assert(translation.x() == 1.0);
- assert(translation.y() == 0.0);
- assert(translation.z() == 0.0);
- }
-
- public void testSimpleTranslationY()
- {
- System.out.println("CoordinateTransformation3DTest.testSimpleTranslationY");
-
- CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(0.0,1.0,0.0));
- CoordinateTransformation3D point = new CoordinateTransformation3D();
- CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
- Hep3Vector translation = result.getTranslation();
- assert(translation.x() == 0.0);
- assert(translation.y() == 1.0);
- assert(translation.z() == 0.0);
- }
-
- public void testSimpleTranslationZ()
- {
- System.out.println("CoordinateTransformation3DTest.testSimpleTranslationZ");
-
- CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(0.0,0.0,1.0));
- CoordinateTransformation3D point = new CoordinateTransformation3D();
- CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
- Hep3Vector translation = result.getTranslation();
- assert(translation.x() == 0.0);
- assert(translation.y() == 0.0);
- assert(translation.z() == 1.0);
- }
-
- public void testSimpleTranslationXYZ()
- {
- System.out.println("CoordinateTransformation3DTest.testSimpleTranslationXYZ");
-
- CoordinateTransformation3D transform = new CoordinateTransformation3D(new BasicHep3Vector(1.0,1.0,1.0));
- CoordinateTransformation3D point = new CoordinateTransformation3D();
- CoordinateTransformation3D result = CoordinateTransformation3D.mult(point, transform);
- Hep3Vector translation = result.getTranslation();
- assert(translation.x() == 1.0);
- assert(translation.y() == 1.0);
- assert(translation.z() == 1.0);
- }
-
- public void testSimpleRotationX()
- {
- System.out.println("CoordinateTransformation3DTest.testSimpleRotationX");
-
- Rotation3D rotateX = new Rotation3D();
- rotateX.setTaitBryan(Math.PI / 4, 0, 0);
- CoordinateTransformation3D transform = new CoordinateTransformation3D(rotateX);
- //CoordinateTransformation3D point = new CoordinateTransformation3D();
- Hep3Vector point = new BasicHep3Vector(1.0,0.0,0.0);
- Hep3Vector result = transform.rotate(point);
- System.out.println("Transform");
- transform.getRotation().printOut(System.out);
- System.out.printf("new point = ( %.4f %.4f %.4f )\n",result.x(),result.y(),result.z());
- //CoordinateTransformation3D.mult(point, transform);
- //Hep3Rotation rotation = result.getRotation();
-
- //System.out.println("transformation");
- //rotateX.printOut(System.out);
- //System.out.println();
- //System.out.println("transformed point");
- //rotation.printOut(System.out);
-
- //assertStrictEquals(rotation, rotateX);
-
- }
-
- public void testRotationIdentity()
- {
- System.out.println("CoordinateTransformation3DTest.testRotationIdentity");
- Rotation3D rotation = new Rotation3D();
- System.out.println("This should be the identity matrix.");
- rotation.printOut(System.out);
- }
-
- private static final void assertStrictEquals(Rotation3D rotate1, Rotation3D rotate2)
- {
- assert(rotate1.xx() == rotate2.xx());
- assert(rotate1.xy() == rotate2.xy());
- assert(rotate1.xz() == rotate2.xz());
- assert(rotate1.yx() == rotate2.yx());
- assert(rotate1.yy() == rotate2.yy());
- assert(rotate1.yz() == rotate2.yz());
- assert(rotate1.zx() == rotate2.zx());
- assert(rotate1.zy() == rotate2.zy());
- assert(rotate1.zz() == rotate2.zz());
- }
-}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector/kernel
diff -N Rotation3DTest.java
--- Rotation3DTest.java 24 Feb 2007 00:30:42 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-package org.lcsim.detector.kernel;
-
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class Rotation3DTest extends TestCase
-{
- public Rotation3DTest(String name)
- {
- super(name);
- }
-
- public static junit.framework.Test suite()
- {
- return new TestSuite(Rotation3DTest.class);
- }
-
- protected void setUp() throws Exception
- {}
-
- public void testIdentityIsDefault()
- {
- Rotation3D rotation = new Rotation3D();
- assert(rotation.getMatrix().trace() == 3.0);
- }
-
- public void testSimpleRotationX()
- {
- Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
- Rotation3D rotation = new Rotation3D();
- rotation.setTaitBryan(Math.PI / 2, 0, 0);
- Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
- System.out.println("90 degree X rotation");
- rotation.printOut(System.out);
- System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
- System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
- rotation.invert();
- result = VecOp.mult(rotation.getMatrix(),result);
- System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
-
- }
-
- public void testSimpleRotationY()
- {
- Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
- Rotation3D rotation = new Rotation3D();
- rotation.setTaitBryan(0, Math.PI / 2, 0);
- Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
- System.out.println("90 degree Y rotation");
- rotation.printOut(System.out);
- System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
- System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
- rotation.invert();
- result = VecOp.mult(rotation.getMatrix(),result);
- System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
- }
-
- public void testSimpleRotationZ()
- {
- Hep3Vector coordinate = new BasicHep3Vector(1.0,0.0,0.0);
- Rotation3D rotation = new Rotation3D();
- rotation.setTaitBryan(0, 0, Math.PI / 2);
- Hep3Vector result = VecOp.mult(rotation.getMatrix(),coordinate);
- System.out.println("90 degree Z rotation");
- rotation.printOut(System.out);
- System.out.printf("original point -> ( %.4f %.4f %.4f ) \n",coordinate.x(),coordinate.y(),coordinate.z());
- System.out.printf("rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
- rotation.invert();
- result = VecOp.mult(rotation.getMatrix(),result);
- System.out.printf("inverse rotated 90 deg -> ( %.4f %.4f %.4f ) \n",result.x(),result.y(),result.z());
- }
-
-}
\ No newline at end of file
CVSspam 0.2.8