Commit in lcsim/test/org/lcsim/spacegeom on MAIN
CylindricalPathTest.java+108added 1.1
CartesianPathTest.java+108added 1.1
SpacePathTest.java+1091.2 -> 1.3
SphericalPathTest.java+108added 1.1
+433
3 added + 1 modified, total 4 files
Added the xxxPathTest to spacegeom tests
fixed the "normalization bug" see FIXMEs
changed .[xyz]() to .getStartPoint.[xyz]()
using JUnit asserts now

lcsim/test/org/lcsim/spacegeom
CylindricalPathTest.java added at 1.1
diff -N CylindricalPathTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CylindricalPathTest.java	1 Sep 2005 04:57:46 -0000	1.1
@@ -0,0 +1,108 @@
+package org.lcsim.spacegeom;
+// CartesianPathTest.cpp
+
+// Test the SpacePath class.
+
+import junit.framework.TestCase;
+
+import org.lcsim.spacegeom.CartesianPath;
+import org.lcsim.spacegeom.CylindricalPath;
+import org.lcsim.spacegeom.SpacePath;
+import org.lcsim.spacegeom.SphericalPath;
+
+public class CylindricalPathTest extends TestCase
+{
+    //**********************************************************************
+    
+    private static final boolean myequal(double x1, double x2)
+    {
+        return Math.abs(x2-x1) < 1.e-10;
+    }
+    
+    //**********************************************************************
+    
+    public void testCylindricalPath()
+    {
+        
+        String name = "CylindricalPath";
+        String ok_prefix = name + " test (I): ";
+        String error_prefix = name + " test (E): ";
+        
+        System.out.println( ok_prefix
+                + "------- Testing component " + name + ". -------" );
+        
+        double x = 1.23;
+        double y = 2.46;
+        double z = 3.69;
+        double dx = 0.23;
+        double dy = 0.45;
+        double dz = 0.67;
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing constructors." );
+        // Create a space path element
+        CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
+        System.out.println( cart );
+        
+        // Create in cylindrical coordinates.
+        CylindricalPath cyl = new CylindricalPath( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
+                cart.drxy(), cart.rxy_dphi(), cart.dz() );
+        System.out.println( cyl );
+        
+        // Create in spherical coordinates.
+        SphericalPath sph = new SphericalPath( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
+                cyl.drxyz(), cyl.rxyz_dtheta(), cyl.rxy_dphi() );
+        System.out.println( sph );
+        
+        assertTrue( myequal(sph.getStartPoint().x(),x) );
+        assertTrue( myequal(sph.getStartPoint().y(),y) );
+        assertTrue( myequal(sph.getStartPoint().z(),z) );
+        assertTrue( myequal(sph.dx(),dx) );
+        assertTrue( myequal(sph.dy(),dy) );
+        assertTrue( myequal(sph.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing assignment." );
+        
+        SpacePath dpth = new SpacePath();
+        System.out.println( dpth );
+        assertTrue( dpth.magnitude() == 0.0 );
+        dpth = sph;
+        System.out.println( dpth );
+        assertTrue( myequal(dpth.getStartPoint().x(),x) );
+        assertTrue( myequal(dpth.getStartPoint().y(),y) );
+        assertTrue( myequal(dpth.getStartPoint().z(),z) );
+        assertTrue( myequal(dpth.dx(),dx) );
+        assertTrue( myequal(dpth.dy(),dy) );
+        assertTrue( myequal(dpth.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing normalizations." );
+        double n0 = dx*dx + dy*dy + dz*dz;
+        System.out.println( n0 );
+        double ncart = dpth.dx()*dpth.dx() +
+                dpth.dy()*dpth.dy() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncart );
+        double ncyl = dpth.drxy()*dpth.drxy() +
+                // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncyl );
+        double nsph = dpth.drxyz()*dpth.drxyz();
+        // FIXME + dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
+        System.out.println( nsph );
+        assertTrue( myequal(ncart,n0) );
+        assertTrue( myequal(ncyl,n0) );
+        assertTrue( myequal(nsph,n0) );
+        assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix
+                + "------------- All tests passed. ------------" );
+        
+    }
+}

lcsim/test/org/lcsim/spacegeom
CartesianPathTest.java added at 1.1
diff -N CartesianPathTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CartesianPathTest.java	1 Sep 2005 04:57:46 -0000	1.1
@@ -0,0 +1,108 @@
+package org.lcsim.spacegeom;
+// CartesianPathTest.cpp
+
+// Test the SpacePath class.
+
+import junit.framework.TestCase;
+
+import org.lcsim.spacegeom.CartesianPath;
+import org.lcsim.spacegeom.CylindricalPath;
+import org.lcsim.spacegeom.SpacePath;
+import org.lcsim.spacegeom.SphericalPath;
+
+public class CartesianPathTest extends TestCase
+{
+    //**********************************************************************
+    
+    private static final boolean myequal(double x1, double x2)
+    {
+        return Math.abs(x2-x1) < 1.e-10;
+    }
+    
+    //**********************************************************************
+    
+    public void testCartesianPath()
+    {
+        
+        String name = "SpacePoint";
+        String ok_prefix = name + " test (I): ";
+        String error_prefix = name + " test (E): ";
+        
+        System.out.println( ok_prefix
+                + "------- Testing component " + name + ". -------" );
+        
+        double x = 1.23;
+        double y = 2.46;
+        double z = 3.69;
+        double dx = 0.23;
+        double dy = 0.45;
+        double dz = 0.67;
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing constructors." );
+        // Create a space path element
+        CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
+        System.out.println( cart );
+        
+        // Create in cylindrical coordinates.
+        CylindricalPath cyl = new CylindricalPath( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
+                cart.drxy(), cart.rxy_dphi(), cart.dz() );
+        System.out.println( cyl );
+        
+        // Create in spherical coordinates.
+        SphericalPath sph = new SphericalPath( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
+                cyl.drxyz(), cyl.rxyz_dtheta(), cyl.rxy_dphi() );
+        System.out.println( sph );
+        
+        assertTrue( myequal(sph.getStartPoint().x(),x) );
+        assertTrue( myequal(sph.getStartPoint().y(),y) );
+        assertTrue( myequal(sph.getStartPoint().z(),z) );
+        assertTrue( myequal(sph.dx(),dx) );
+        assertTrue( myequal(sph.dy(),dy) );
+        assertTrue( myequal(sph.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing assignment." );
+        
+        SpacePath dpth = new SpacePath();
+        System.out.println( dpth );
+        assertTrue( dpth.magnitude() == 0.0 );
+        dpth = sph;
+        System.out.println( dpth );
+        assertTrue( myequal(dpth.getStartPoint().x(),x) );
+        assertTrue( myequal(dpth.getStartPoint().y(),y) );
+        assertTrue( myequal(dpth.getStartPoint().z(),z) );
+        assertTrue( myequal(dpth.dx(),dx) );
+        assertTrue( myequal(dpth.dy(),dy) );
+        assertTrue( myequal(dpth.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing normalizations." );
+        double n0 = dx*dx + dy*dy + dz*dz;
+        System.out.println( n0 );
+        double ncart = dpth.dx()*dpth.dx() +
+                dpth.dy()*dpth.dy() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncart );
+        double ncyl = dpth.drxy()*dpth.drxy() +
+                // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncyl );
+        double nsph = dpth.drxyz()*dpth.drxyz();
+                // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
+        System.out.println( nsph );
+        assertTrue( myequal(ncart,n0) );
+        assertTrue( myequal(ncyl,n0) );
+        assertTrue( myequal(nsph,n0) );
+        assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix
+                + "------------- All tests passed. ------------" );
+        
+    }
+}

lcsim/test/org/lcsim/spacegeom
SpacePathTest.java 1.2 -> 1.3
diff -N SpacePathTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SpacePathTest.java	1 Sep 2005 04:57:46 -0000	1.3
@@ -0,0 +1,109 @@
+package org.lcsim.spacegeom;
+// SpacePathTest.cpp
+
+// Test the SpacePath class.
+
+import junit.framework.TestCase;
+
+import org.lcsim.spacegeom.CartesianPath;
+import org.lcsim.spacegeom.CylindricalPath;
+import org.lcsim.spacegeom.SpacePath;
+import org.lcsim.spacegeom.SphericalPath;
+
+public class SpacePathTest extends TestCase
+{
+    //**********************************************************************
+    
+    private static final boolean myequal(double x1, double x2)
+    {
+        return Math.abs(x2-x1) < 1.e-10;
+    }
+    
+    //**********************************************************************
+    
+    public void testSpacePath()
+    {
+        
+        String name = "SpacePoint";
+        String ok_prefix = name + " test (I): ";
+        String error_prefix = name + " test (E): ";
+        
+        System.out.println( ok_prefix
+                + "------- Testing component " + name + ". -------" );
+        
+        double x = 1.23;
+        double y = 2.46;
+        double z = 3.69;
+        double dx = 0.23;
+        double dy = 0.45;
+        double dz = 0.67;
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing constructors." );
+        // Create a space path element
+        CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
+        System.out.println( cart );
+        
+        // Create in cylindrical coordinates.
+        CylindricalPath cyl = new CylindricalPath( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
+                cart.drxy(), cart.rxy_dphi(), cart.dz() );
+        System.out.println( cyl );
+        
+        // Create in spherical coordinates.
+        SphericalPath sph = new SphericalPath( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
+                cyl.drxyz(), cyl.rxyz_dtheta(), cyl.rxy_dphi() );
+        System.out.println( sph );
+        
+        assertTrue( myequal(sph.getStartPoint().x(),x) );
+        assertTrue( myequal(sph.getStartPoint().y(),y) );
+        assertTrue( myequal(sph.getStartPoint().z(),z) );
+        assertTrue( myequal(sph.dx(),dx) );
+        assertTrue( myequal(sph.dy(),dy) );
+        assertTrue( myequal(sph.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing assignment." );
+        
+        SpacePath dpth = new SpacePath();
+        System.out.println( dpth );
+        assertTrue( dpth.magnitude() == 0.0 );
+        dpth = sph;
+        System.out.println( dpth );
+        assertTrue( myequal(dpth.getStartPoint().x(),x) );
+        assertTrue( myequal(dpth.getStartPoint().y(),y) );
+        assertTrue( myequal(dpth.getStartPoint().z(),z) );
+        assertTrue( myequal(dpth.dx(),dx) );
+        assertTrue( myequal(dpth.dy(),dy) );
+        assertTrue( myequal(dpth.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing normalizations." );
+        double n0 = dx*dx + dy*dy + dz*dz;
+        System.out.println( n0 );
+        double ncart = dpth.dx()*dpth.dx() +
+                dpth.dy()*dpth.dy() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncart );
+        double ncyl = dpth.drxy()*dpth.drxy() +
+        // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncyl );
+        double nsph = dpth.drxyz()*dpth.drxyz();
+                // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
+                // FIXME dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
+        System.out.println( nsph );
+        assertTrue( myequal(ncart,n0) );
+        assertTrue( myequal(ncyl,n0) );
+        assertTrue( myequal(nsph,n0) );
+        assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix
+                + "------------- All tests passed. ------------" );
+        
+    }
+}

lcsim/test/org/lcsim/spacegeom
SphericalPathTest.java added at 1.1
diff -N SphericalPathTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SphericalPathTest.java	1 Sep 2005 04:57:46 -0000	1.1
@@ -0,0 +1,108 @@
+package org.lcsim.spacegeom;
+// CartesianPathTest.cpp
+
+// Test the SpacePath class.
+
+import junit.framework.TestCase;
+
+import org.lcsim.spacegeom.CartesianPath;
+import org.lcsim.spacegeom.CylindricalPath;
+import org.lcsim.spacegeom.SpacePath;
+import org.lcsim.spacegeom.SphericalPath;
+
+public class SphericalPathTest extends TestCase
+{
+    //**********************************************************************
+    
+    private static final boolean myequal(double x1, double x2)
+    {
+        return Math.abs(x2-x1) < 1.e-10;
+    }
+    
+    //**********************************************************************
+    
+    public void testSphericalPath()
+    {
+        
+        String name = "SphericalPath";
+        String ok_prefix = name + " test (I): ";
+        String error_prefix = name + " test (E): ";
+        
+        System.out.println( ok_prefix
+                + "------- Testing component " + name + ". -------" );
+        
+        double x = 1.23;
+        double y = 2.46;
+        double z = 3.69;
+        double dx = 0.23;
+        double dy = 0.45;
+        double dz = 0.67;
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing constructors." );
+        // Create a space path element
+        CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
+        System.out.println( cart );
+        
+        // Create in cylindrical coordinates.
+        CylindricalPath cyl = new CylindricalPath( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
+                cart.drxy(), cart.rxy_dphi(), cart.dz() );
+        System.out.println( cyl );
+        
+        // Create in spherical coordinates.
+        SphericalPath sph = new SphericalPath( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
+                cyl.drxyz(), cyl.rxyz_dtheta(), cyl.rxy_dphi() );
+        System.out.println( sph );
+        
+        assertTrue( myequal(sph.getStartPoint().x(),x) );
+        assertTrue( myequal(sph.getStartPoint().y(),y) );
+        assertTrue( myequal(sph.getStartPoint().z(),z) );
+        assertTrue( myequal(sph.dx(),dx) );
+        assertTrue( myequal(sph.dy(),dy) );
+        assertTrue( myequal(sph.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing assignment." );
+        
+        SpacePath dpth = new SpacePath();
+        System.out.println( dpth );
+        assertTrue( dpth.magnitude() == 0.0 );
+        dpth = sph;
+        System.out.println( dpth );
+        assertTrue( myequal(dpth.getStartPoint().x(),x) );
+        assertTrue( myequal(dpth.getStartPoint().y(),y) );
+        assertTrue( myequal(dpth.getStartPoint().z(),z) );
+        assertTrue( myequal(dpth.dx(),dx) );
+        assertTrue( myequal(dpth.dy(),dy) );
+        assertTrue( myequal(dpth.dz(),dz) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix + "Testing normalizations." );
+        double n0 = dx*dx + dy*dy + dz*dz;
+        System.out.println( n0 );
+        double ncart = dpth.dx()*dpth.dx() +
+                dpth.dy()*dpth.dy() +
+                dpth.dz()*dpth.dz();
+        System.out.println( ncart );
+        double ncyl = dpth.drxy()*dpth.drxy() +
+                 // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
+                 dpth.dz()*dpth.dz();
+        System.out.println( ncyl );
+        double nsph = dpth.drxyz()*dpth.drxyz();
+                // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
+        System.out.println( nsph );
+        assertTrue( myequal(ncart,n0) );
+        assertTrue( myequal(ncyl,n0) );
+        assertTrue( myequal(nsph,n0) );
+        assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
+        
+        //**********************************************************************
+        
+        System.out.println( ok_prefix
+                + "------------- All tests passed. ------------" );
+        
+    }
+}
CVSspam 0.2.8