Print

Print


Commit in GeomConverter/test/org/lcsim/detector on MAIN
Transform3DTest.java+251added 1.1
CoordinateTransformation3DTest.java-2241.8 removed
+251-224
1 added + 1 removed, total 2 files
JM: Change name of test case.

GeomConverter/test/org/lcsim/detector
Transform3DTest.java added at 1.1
diff -N Transform3DTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Transform3DTest.java	30 Mar 2007 23:26:54 -0000	1.1
@@ -0,0 +1,251 @@
+package org.lcsim.detector;
+
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Rotation3D;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.VecOp;
+import hep.physics.vec.Hep3Vector;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import java.util.Random;
+
+import static java.lang.Math.PI;
+
+public class Transform3DTest extends TestCase
+{		
+    public Transform3DTest(String name)
+    {
+        super(name);
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new TestSuite(Transform3DTest.class);
+    }
+    
+    protected void setUp() throws Exception
+    {}
+    
+    public void testSimpleTransform()
+    {        
+        Rotation3D r1 = new Rotation3D();
+        r1.setPassiveXYZ(0, 0, PI/2);
+        
+        Hep3Vector v1 = new BasicHep3Vector(10,0,0);
+        
+        Transform3D t1 = new Transform3D(v1,r1);
+        
+        Hep3Vector point = new BasicHep3Vector(1,0,0);
+        
+        Hep3Vector tpoint = VecOp.mult(r1.getRotationMatrix(), point);
+        
+        //System.out.println("point = " + tpoint);
+        
+        Hep3Vector tpoint2 = VecOp.add(tpoint, t1.getTranslation());
+        
+        //System.out.println("point2 = " + tpoint2);
+        
+        System.out.println(t1.transformed(point));
+        
+        assertTrue(t1.transformed(point).equals(tpoint2));
+    }
+       
+    public void testIdentityTransformation()
+    {
+    	System.out.println("CoordinateTransformation3DTest.testIdentityTransformation");
+    	
+    	Transform3D transformation = new Transform3D();     
+    	Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
+    	
+    	Hep3Vector transformed_point = transformation.transformed(point);
+    	assertEquals(transformed_point.x(),point.x());
+    	assertEquals(transformed_point.y(),point.y());
+    	assertEquals(transformed_point.z(),point.z());
+    }    
+    
+    public void testSimpleTranslationXYZ()
+    {
+    	System.out.println("CoordinateTransformation3DTest.testSimpleTranslationXYZ");
+    	
+        Random random = new Random();
+        double random_x = random.nextDouble();
+        double random_y = random.nextDouble();
+        double random_z = random.nextDouble();
+        
+    	Transform3D transformation = new Transform3D(new BasicHep3Vector(random_x,random_y,random_z));
+    	Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
+
+    	Hep3Vector transformed_point = transformation.transformed(point);
+        
+//        System.out.println("x_1: "+(point.x()+random_x)+"  x_2: "+transformed_point.x());
+//        System.out.println("y_1: "+(point.y()+random_y)+"  y_2: "+transformed_point.y());
+//        System.out.println("z_1: "+(point.z()+random_z)+"  z_2: "+transformed_point.z());
+        
+    	assertEquals(transformed_point.x(),point.x()+random_x);
+    	assertEquals(transformed_point.y(),point.y()+random_y);
+    	assertEquals(transformed_point.z(),point.z()+random_z);
+        
+    }
+    
+    
+    public void testSimpleRotationX()
+    {
+    	System.out.println("CoordinateTransformation3DTest.testSimpleRotationX");
+    	
+    	Rotation3D rotateX = new Rotation3D();
+        
+    	rotateX.setPassiveXYZ(Math.PI / 2, 0, 0);
+    	Transform3D transformation = new Transform3D(rotateX);
+
+    	Hep3Vector point = new BasicHep3Vector(0.0,0.0,1.0);
+    	Hep3Vector result = transformation.transformed(point);
+
+//    	System.out.println("Transform");
+    	transformation.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 testMultiply()
+    {
+        
+        System.out.println("CoordinateTransformation3DTest.testMultiply");
+    	
+        Random random = new Random();
+        
+        Rotation3D rotation_1 = new Rotation3D();
+        rotation_1.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation_1 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        
+        Rotation3D rotation_2 = new Rotation3D();
+        rotation_2.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation_2 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+
+    	Transform3D transformation_1 = new Transform3D(translation_1,rotation_1);
+    	Transform3D transformation_2 = new Transform3D(translation_2,rotation_2);
+       
+        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
+        
+        Hep3Vector transformed_point_1 = transformation_1.transformed(point);
+        transformed_point_1 = transformation_2.transformed(transformed_point_1);
+       
+        Transform3D transformation_product = Transform3D.multiply(transformation_2,transformation_1);
+        Hep3Vector transformed_point_2 = transformation_product.transformed(point);
+        
+        System.out.println("x_1: "+transformed_point_1.x()+"  x_2: "+transformed_point_2.x());
+        System.out.println("y_1: "+transformed_point_1.y()+"  y_2: "+transformed_point_2.y());
+        System.out.println("z_1: "+transformed_point_1.z()+"  z_2: "+transformed_point_2.z());
+
+        assertTrue(Math.abs(transformed_point_2.x()/transformed_point_1.x()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point_2.y()/transformed_point_1.y()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point_2.z()/transformed_point_1.z()-1) < 1E-12);
+        
+    }
+
+    
+    public void testMultiplyBy()
+    {
+        
+        System.out.println("CoordinateTransformation3DTest.testMultiplyBy");
+    	
+        Random random = new Random();
+        
+        Rotation3D rotation_1 = new Rotation3D();
+        rotation_1.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation_1 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        
+        Rotation3D rotation_2 = new Rotation3D();
+        rotation_2.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation_2 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+
+    	Transform3D transformation_1 = new Transform3D(translation_1,rotation_1);
+    	Transform3D transformation_2 = new Transform3D(translation_2,rotation_2);
+        
+        Hep3Vector point_1 = new BasicHep3Vector(1.0,2.0,3.0);
+        Hep3Vector point_2 = new BasicHep3Vector(1.0,2.0,3.0);
+                
+        transformation_1.transform(point_1);
+        transformation_2.transform(point_1);
+        
+        transformation_2.multiplyBy(transformation_1);        
+        transformation_2.transform(point_2);
+        
+        System.out.println("x_1: "+point_1.x()+"  x_2: "+point_2.x());
+        System.out.println("y_1: "+point_1.y()+"  y_2: "+point_2.y());
+        System.out.println("z_1: "+point_1.z()+"  z_2: "+point_2.z());
+
+        assertTrue(Math.abs(point_2.x()/point_1.x()-1) < 1E-12);
+    	assertTrue(Math.abs(point_2.y()/point_1.y()-1) < 1E-12);
+    	assertTrue(Math.abs(point_2.z()/point_1.z()-1) < 1E-12);
+        
+    }
+    
+    
+    public void testInvert()
+    {
+        
+        System.out.println("CoordinateTransformation3DTest.testInvert");
+    	
+        Random random = new Random();
+
+        Rotation3D rotation = new Rotation3D();
+        rotation.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+    	Transform3D transformation = new Transform3D(translation,rotation);
+        
+        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
+        Hep3Vector transformed_point = transformation.transformed(point);
+        
+        transformation.invert();
+        transformed_point = transformation.transformed(transformed_point);
+
+//        System.out.println("x ratio: "+transformed_point.x()/point.x());
+//        System.out.println("y ratio: "+transformed_point.y()/point.y());
+//        System.out.println("z ratio: "+transformed_point.z()/point.z());
+        
+        assertTrue(Math.abs(transformed_point.x()/point.x()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point.y()/point.y()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point.z()/point.z()-1) < 1E-12);
+        
+    }
+
+    
+    public void testInverse()
+    {
+        
+        System.out.println("CoordinateTransformation3DTest.testInverse");
+    	
+        Random random = new Random();
+
+        Rotation3D rotation = new Rotation3D();
+        rotation.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
+        Hep3Vector translation = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
+
+    	Transform3D transformation = new Transform3D(translation,rotation);  
+        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);        
+        Hep3Vector transformed_point = transformation.transformed(point);     
+        
+        Transform3D transformation_inverted = transformation.inverse();
+        transformed_point = transformation_inverted.transformed(transformed_point);
+        
+//        System.out.println("x ratio: "+transformed_point.x()/point.x());
+//        System.out.println("y ratio: "+transformed_point.y()/point.y());
+//        System.out.println("z ratio: "+transformed_point.z()/point.z());
+        
+    	assertTrue(Math.abs(transformed_point.x()/point.x()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point.y()/point.y()-1) < 1E-12);
+    	assertTrue(Math.abs(transformed_point.z()/point.z()-1) < 1E-12);
+        
+    } 
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/detector
CoordinateTransformation3DTest.java removed after 1.8
diff -N CoordinateTransformation3DTest.java
--- CoordinateTransformation3DTest.java	29 Mar 2007 22:01:07 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,224 +0,0 @@
-package org.lcsim.detector;
-
-import org.lcsim.detector.Transform3D;
-import org.lcsim.detector.Rotation3D;
-
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import java.util.Random;
-
-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");
-    	
-    	Transform3D transformation = new Transform3D();     
-    	Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
-    	
-    	Hep3Vector transformed_point = transformation.transformed(point);
-    	assertEquals(transformed_point.x(),point.x());
-    	assertEquals(transformed_point.y(),point.y());
-    	assertEquals(transformed_point.z(),point.z());
-    }    
-    
-    public void testSimpleTranslationXYZ()
-    {
-    	System.out.println("CoordinateTransformation3DTest.testSimpleTranslationXYZ");
-    	
-        Random random = new Random();
-        double random_x = random.nextDouble();
-        double random_y = random.nextDouble();
-        double random_z = random.nextDouble();
-        
-    	Transform3D transformation = new Transform3D(new BasicHep3Vector(random_x,random_y,random_z));
-    	Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
-
-    	Hep3Vector transformed_point = transformation.transformed(point);
-        
-//        System.out.println("x_1: "+(point.x()+random_x)+"  x_2: "+transformed_point.x());
-//        System.out.println("y_1: "+(point.y()+random_y)+"  y_2: "+transformed_point.y());
-//        System.out.println("z_1: "+(point.z()+random_z)+"  z_2: "+transformed_point.z());
-        
-    	assertEquals(transformed_point.x(),point.x()+random_x);
-    	assertEquals(transformed_point.y(),point.y()+random_y);
-    	assertEquals(transformed_point.z(),point.z()+random_z);
-        
-    }
-    
-    
-    public void testSimpleRotationX()
-    {
-    	System.out.println("CoordinateTransformation3DTest.testSimpleRotationX");
-    	
-    	Rotation3D rotateX = new Rotation3D();
-        
-    	rotateX.setPassiveXYZ(Math.PI / 2, 0, 0);
-    	Transform3D transformation = new Transform3D(rotateX);
-
-    	Hep3Vector point = new BasicHep3Vector(0.0,0.0,1.0);
-    	Hep3Vector result = transformation.transformed(point);
-
-//    	System.out.println("Transform");
-    	transformation.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 testMultiply()
-    {
-        
-        System.out.println("CoordinateTransformation3DTest.testMultiply");
-    	
-        Random random = new Random();
-        
-        Rotation3D rotation_1 = new Rotation3D();
-        rotation_1.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation_1 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        
-        Rotation3D rotation_2 = new Rotation3D();
-        rotation_2.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation_2 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-
-    	Transform3D transformation_1 = new Transform3D(translation_1,rotation_1);
-    	Transform3D transformation_2 = new Transform3D(translation_2,rotation_2);
-       
-        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
-        
-        Hep3Vector transformed_point_1 = transformation_1.transformed(point);
-        transformed_point_1 = transformation_2.transformed(transformed_point_1);
-       
-        Transform3D transformation_product = Transform3D.multiply(transformation_2,transformation_1);
-        Hep3Vector transformed_point_2 = transformation_product.transformed(point);
-        
-        System.out.println("x_1: "+transformed_point_1.x()+"  x_2: "+transformed_point_2.x());
-        System.out.println("y_1: "+transformed_point_1.y()+"  y_2: "+transformed_point_2.y());
-        System.out.println("z_1: "+transformed_point_1.z()+"  z_2: "+transformed_point_2.z());
-
-        assertTrue(Math.abs(transformed_point_2.x()/transformed_point_1.x()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point_2.y()/transformed_point_1.y()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point_2.z()/transformed_point_1.z()-1) < 1E-12);
-        
-    }
-
-    
-    public void testMultiplyBy()
-    {
-        
-        System.out.println("CoordinateTransformation3DTest.testMultiplyBy");
-    	
-        Random random = new Random();
-        
-        Rotation3D rotation_1 = new Rotation3D();
-        rotation_1.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation_1 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        
-        Rotation3D rotation_2 = new Rotation3D();
-        rotation_2.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation_2 = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-
-    	Transform3D transformation_1 = new Transform3D(translation_1,rotation_1);
-    	Transform3D transformation_2 = new Transform3D(translation_2,rotation_2);
-        
-        Hep3Vector point_1 = new BasicHep3Vector(1.0,2.0,3.0);
-        Hep3Vector point_2 = new BasicHep3Vector(1.0,2.0,3.0);
-                
-        transformation_1.transform(point_1);
-        transformation_2.transform(point_1);
-        
-        transformation_2.multiplyBy(transformation_1);        
-        transformation_2.transform(point_2);
-        
-        System.out.println("x_1: "+point_1.x()+"  x_2: "+point_2.x());
-        System.out.println("y_1: "+point_1.y()+"  y_2: "+point_2.y());
-        System.out.println("z_1: "+point_1.z()+"  z_2: "+point_2.z());
-
-        assertTrue(Math.abs(point_2.x()/point_1.x()-1) < 1E-12);
-    	assertTrue(Math.abs(point_2.y()/point_1.y()-1) < 1E-12);
-    	assertTrue(Math.abs(point_2.z()/point_1.z()-1) < 1E-12);
-        
-    }
-    
-    
-    public void testInvert()
-    {
-        
-        System.out.println("CoordinateTransformation3DTest.testInvert");
-    	
-        Random random = new Random();
-
-        Rotation3D rotation = new Rotation3D();
-        rotation.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-    	Transform3D transformation = new Transform3D(translation,rotation);
-        
-        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);
-        Hep3Vector transformed_point = transformation.transformed(point);
-        
-        transformation.invert();
-        transformed_point = transformation.transformed(transformed_point);
-
-//        System.out.println("x ratio: "+transformed_point.x()/point.x());
-//        System.out.println("y ratio: "+transformed_point.y()/point.y());
-//        System.out.println("z ratio: "+transformed_point.z()/point.z());
-        
-        assertTrue(Math.abs(transformed_point.x()/point.x()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point.y()/point.y()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point.z()/point.z()-1) < 1E-12);
-        
-    }
-
-    
-    public void testInverse()
-    {
-        
-        System.out.println("CoordinateTransformation3DTest.testInverse");
-    	
-        Random random = new Random();
-
-        Rotation3D rotation = new Rotation3D();
-        rotation.setPassiveXYZ(random.nextDouble(),random.nextDouble(),random.nextDouble());
-        Hep3Vector translation = new BasicHep3Vector(random.nextDouble(),random.nextDouble(),random.nextDouble());
-
-    	Transform3D transformation = new Transform3D(translation,rotation);  
-        Hep3Vector point = new BasicHep3Vector(1.0,2.0,3.0);        
-        Hep3Vector transformed_point = transformation.transformed(point);     
-        
-        Transform3D transformation_inverted = transformation.inverse();
-        transformed_point = transformation_inverted.transformed(transformed_point);
-        
-//        System.out.println("x ratio: "+transformed_point.x()/point.x());
-//        System.out.println("y ratio: "+transformed_point.y()/point.y());
-//        System.out.println("z ratio: "+transformed_point.z()/point.z());
-        
-    	assertTrue(Math.abs(transformed_point.x()/point.x()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point.y()/point.y()-1) < 1E-12);
-    	assertTrue(Math.abs(transformed_point.z()/point.z()-1) < 1E-12);
-        
-    } 
-}
\ No newline at end of file
CVSspam 0.2.8