18 removed files
lcsim/test/org/lcsim/spacegeom
diff -N CartesianPathTest.java
--- CartesianPathTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-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
-{
- //**********************************************************************
- boolean debug = false;
- 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): ";
-
- if (debug) 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;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space path element
- CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
- if (debug) 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() );
- if (debug) 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() );
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
-
- SpacePath dpth = new SpacePath();
- if (debug) System.out.println( dpth );
- assertTrue( dpth.magnitude() == 0.0 );
- dpth = sph;
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = dx*dx + dy*dy + dz*dz;
- if (debug) System.out.println( n0 );
- double ncart = dpth.dx()*dpth.dx() +
- dpth.dy()*dpth.dy() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncart );
- double ncyl = dpth.drxy()*dpth.drxy() +
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncyl );
- double nsph = dpth.drxyz()*dpth.drxyz();
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
- if (debug) System.out.println( nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N CartesianPointTest.java
--- CartesianPointTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,113 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CylindricalPoint;
-import org.lcsim.spacegeom.SphericalPoint;
-
-import org.lcsim.spacegeom.SpacePoint;
-
-public class CartesianPointTest extends TestCase
-{
- boolean debug = false;
- // SpacePointTest.java
-
- // Test the SpacePoint class.
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-12;
- }
-
- //**********************************************************************
- double x;
- double y;
- double z;
- String name;
- String ok_prefix;
- String error_prefix;
-
- public void setUp() throws Exception {
- super.setUp();
- x = 1.23;
- y = 2.46;
- z = 3.69;
-
- name = "CartesianPoint";
- ok_prefix = name + " test (I): ";
- error_prefix = name + " test (E): ";
- if (debug) System.out.println(" ----- Testing component " + name + ". -------");
- }
-
- public void testCartesianPoint() {
- if (debug) System.out.println(ok_prefix + "Testing constructors.");
- // Create a space point
- CartesianPoint cart = new CartesianPoint(x,y,z);
- if (debug) System.out.println(cart);
-
- // Create in cylindrical coordinates.
- CylindricalPoint cyl = new CylindricalPoint( cart.rxy(), cart.phi(), cart.z() );
- if (debug) System.out.println(cyl);
-
- // Create in spherical coordinates.
- SphericalPoint sph = new SphericalPoint( cyl.rxyz(), cyl.phi(), cyl.theta() );
- if (debug) System.out.println(sph);
-
- assertTrue( myequal(sph.x(),x) ||
- myequal(sph.y(),y) ||
- myequal(sph.z(),z) );
- if (debug) System.out.println( ok_prefix + "Testing assignment.");
- SpacePoint spt = new SpacePoint();
- if (debug) System.out.println(spt);
- spt = sph;
- if (debug) System.out.println(spt);
- assertTrue( myequal(spt.x(),sph.x()) ||
- myequal(spt.y(),sph.y()) ||
- myequal(spt.z(),sph.z()) );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test cos and sin returns.");
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ));
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ));
- assertTrue( myequal( spt.cosTheta(), Math.cos( spt.theta() ) ));
- assertTrue( myequal( spt.sinTheta(), Math.sin( spt.theta() ) ));
-
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test equality.");
- CartesianPoint spt2 = new CartesianPoint(spt.x(),spt.y(),spt.z());
- assertTrue( spt.equals(spt2));
- assertTrue( !spt.notEquals(spt2) );
- if (debug) System.out.println(" spt = spt2" );
- CartesianPoint spt3 = new CartesianPoint(spt.x()+0.1,spt.y(),spt.z());
- assertTrue( spt.notEquals(spt3) );
- assertTrue( !spt.equals(spt3) );
- if (debug) System.out.println(" spt != spt3" );
- CartesianPoint spt4 = new CartesianPoint(spt.x(),spt.y()+0.2,spt.z());
- assertTrue( spt.notEquals(spt4));
- if (debug) System.out.println(" spt != spt4" );
- CartesianPoint spt5 = new CartesianPoint(spt.x(),spt.y(),spt.z()+0.3);
- assertTrue( spt.notEquals(spt5));
- if (debug) System.out.println(" spt != spt5" );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test distance function.");
- assertTrue( SpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dz = 3.3;
- double dist0 = Math.sqrt(dx*dx+dy*dy+dz*dz);
- CartesianPoint cart2 = new CartesianPoint(x+dx,y+dy,z+dz);
- if (debug) System.out.println(cart2);
- double dist = SpacePoint.distance(cart,cart2);
- if (debug) System.out.println("Distance = " + dist0 + " " + dist);
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------");
- }
-}
-
-
lcsim/test/org/lcsim/spacegeom
diff -N CartesianPointVectorTest.java
--- CartesianPointVectorTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,141 +0,0 @@
-package org.lcsim.spacegeom;
-// SpacePointVecTest.cpp
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPointVector;
-import org.lcsim.spacegeom.CylindricalPointVector;
-import org.lcsim.spacegeom.SpacePointVector;
-import org.lcsim.spacegeom.SphericalPointVector;
-
-// Test the SpacePointVector class.
-
-public class CartesianPointVectorTest extends TestCase
-{
- boolean debug = false;
- //**********************************************************************
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-10;
- }
-
- //**********************************************************************
-
- public void testCartesianPointVector()
- {
-
- String name = "CartesianPointVector";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- double vx = 0.23;
- double vy = 0.45;
- double vz = 0.67;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a spacevector
- CartesianPointVector cart = new CartesianPointVector(x,y,z,vx,vy,vz);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl = new CylindricalPointVector( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
- cart.v_rxy(), cart.v_phi(), cart.v_z() );
- if (debug) System.out.println( cyl );
-
- // Create in spherical coordinates.
- SphericalPointVector sph = new SphericalPointVector( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
- cyl.v_rxyz(), cyl.v_theta(), cyl.v_phi() );
- if (debug) 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.v_x(),vx) );
- assertTrue( myequal(sph.v_y(),vy) );
- assertTrue( myequal(sph.v_z(),vz) );
-
- // Create a cartesian coordinates from spacepoint
- CartesianPointVector cart2 = new CartesianPointVector( sph.getStartPoint(), sph.v_x(), sph.v_y(), sph.v_z() );
- if (debug) System.out.println( cart2 );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl2 = new CylindricalPointVector( cart2.getStartPoint(),
- cart2.v_rxy(), cart2.v_phi(), cart2.v_z() );
- if (debug) System.out.println( cyl2 );
-
- // Create in spherical coordinates.
- SphericalPointVector sph2 = new SphericalPointVector( cyl2.getStartPoint(),
- cyl2.v_rxyz(), cyl2.v_theta(), cyl2.v_phi() );
- if (debug) System.out.println( sph2 );
-
- assertTrue( myequal(sph2.getStartPoint().x(),x) );
- assertTrue( myequal(sph2.getStartPoint().y(),y) );
- assertTrue( myequal(sph2.getStartPoint().z(),z) );
- assertTrue( myequal(sph2.v_x(),vx) );
- assertTrue( myequal(sph2.v_y(),vy) );
- assertTrue( myequal(sph2.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing equality." );
- assertTrue( sph.equals(sph) );
- assertTrue( sph.equals(sph2) );
- if( sph.notEquals(sph2) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- SpacePointVector svec = new SpacePointVector();
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.magnitude() and 0 " + svec.magnitude() + " " + 0. );
- if (debug) System.out.println( "spacepoint equal " + (svec.magnitude()==0.0) );
- // Assert.assertTrue( SpacePoint.equal(svec.magnitude(),0.0) );
- svec = sph;
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.x() and x " + svec.getStartPoint().x() + " " + x );
- assertTrue( myequal(svec.getStartPoint().x(),x) );
- assertTrue( myequal(svec.getStartPoint().y(),y) );
- assertTrue( myequal(svec.getStartPoint().z(),z) );
- assertTrue( myequal(svec.v_x(),vx) );
- assertTrue( myequal(svec.v_y(),vy) );
- assertTrue( myequal(svec.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = vx*vx + vy*vy + vz*vz;
- if (debug) System.out.println( "n0= " +n0 );
- double ncart = svec.v_x()*svec.v_x() +
- svec.v_y()*svec.v_y() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncart= " +ncart );
- double ncyl = svec.v_rxy()*svec.v_rxy() +
- // FIXME if this worked before, there is a serious problem svec.v_phi()*svec.v_phi() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncyl= " +ncyl );
- double nsph = svec.v_rxyz()*svec.v_rxyz();
- // FIXME this might really indicate a problem + svec.v_theta()*svec.v_theta() + svec.v_phi()*svec.v_phi();
- if (debug) System.out.println( "nsph= " +nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), svec.magnitude() ) );
- //
- if (debug) System.out.println("Testing copy constructor and clone");
- SpacePointVector spv = (SpacePointVector) svec.clone();
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
- }
-
-}
\ No newline at end of file
lcsim/test/org/lcsim/spacegeom
diff -N CartesianTwoPointTest.java
--- CartesianTwoPointTest.java 7 Sep 2005 01:09:55 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-package org.lcsim.spacegeom;
-//package spacegeom;
-// Test the spacepoint class.
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianTwoPoint;
-import org.lcsim.spacegeom.CylindricalTwoPoint;
-import org.lcsim.spacegeom.TwoSpacePoint;
-
-
-public class CartesianTwoPointTest extends TestCase
-{
- boolean debug = false;
- private static boolean myequal(double x1, double x2)
- {
- return (Math.abs(x2-x1) < 1.e-12);
- }
-
- //**********************************************************************
-
- public void testCartesianPoint()
- {
-
- String name = "CartesianTwoPoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space point
- CartesianTwoPoint cart = new CartesianTwoPoint(x,y);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalTwoPoint cyl = new CylindricalTwoPoint( cart.rxy(), cart.phi() );
- if (debug) System.out.println( cyl );
-
- if ( ! myequal(cyl.x(),x) || ! myequal(cyl.y(),y) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- TwoSpacePoint spt = new TwoSpacePoint();
- if (debug) System.out.println( spt );
- spt = cyl;
- if (debug) System.out.println( spt );
- if ( ! myequal(spt.x(),cyl.x()) || ! myequal(spt.y(),cyl.y()) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test cos and sin returns." );
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ) );
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test equality." );
- CartesianTwoPoint spt2 = new CartesianTwoPoint(spt.x(),spt.y());
- assertTrue( spt.equals(spt2) );
- assertTrue( ! (spt.notEquals(spt2)) );
- CartesianTwoPoint spt3 = new CartesianTwoPoint(spt.x()+0.1,spt.y());
- assertTrue( ! (spt.equals(spt3)) );
- assertTrue( spt.notEquals(spt3) );
- CartesianTwoPoint spt4 = new CartesianTwoPoint(spt.x(),spt.y()+0.2);
- assertTrue( spt.notEquals(spt4) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test distance function." );
- assertTrue( TwoSpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dist0 = Math.sqrt(dx*dx+dy*dy);
- CartesianTwoPoint cart2 = new CartesianTwoPoint(x+dx,y+dy);
- if (debug) System.out.println( cart );
- if (debug) System.out.println( cart2 );
- double dist = TwoSpacePoint.distance(cart,cart2);
- if (debug) System.out.println( "Distance = " + dist0 + " " + dist );
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N CylindricalPathTest.java
--- CylindricalPathTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-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
-{
- //**********************************************************************
- boolean debug = false;
- 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): ";
-
- if (debug) 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;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space path element
- CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
- if (debug) 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() );
- if (debug) 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() );
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
-
- SpacePath dpth = new SpacePath();
- if (debug) System.out.println( dpth );
- assertTrue( dpth.magnitude() == 0.0 );
- dpth = sph;
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = dx*dx + dy*dy + dz*dz;
- if (debug) System.out.println( n0 );
- double ncart = dpth.dx()*dpth.dx() +
- dpth.dy()*dpth.dy() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncart );
- double ncyl = dpth.drxy()*dpth.drxy() +
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncyl );
- double nsph = dpth.drxyz()*dpth.drxyz();
- // FIXME + dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
- if (debug) System.out.println( nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N CylindricalPointTest.java
--- CylindricalPointTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CylindricalPoint;
-import org.lcsim.spacegeom.SphericalPoint;
-
-import org.lcsim.spacegeom.SpacePoint;
-
-public class CylindricalPointTest extends TestCase
-{
- boolean debug = false;
- // SpacePointTest.java
-
- // Test the SpacePoint class.
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-12;
- }
-
- //**********************************************************************
-
- public void testCylindricalPoint()
- {
-
- String name = "CylindricalPoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
- if (debug) System.out.println(" ----- Testing component " + name + ". -------");
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Testing constructors.");
- // Create a space point
- CartesianPoint cart = new CartesianPoint(x,y,z);
- if (debug) System.out.println(cart);
-
- // Create in cylindrical coordinates.
- CylindricalPoint cyl = new CylindricalPoint( cart.rxy(), cart.phi(), cart.z() );
- if (debug) System.out.println(cyl);
-
- // Create in spherical coordinates.
- SphericalPoint sph = new SphericalPoint( cyl.rxyz(), cyl.phi(), cyl.theta() );
- if (debug) System.out.println(sph);
-
- assertTrue( myequal(sph.x(),x) ||
- myequal(sph.y(),y) ||
- myequal(sph.z(),z) );
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment.");
- SpacePoint spt = new SpacePoint();
- if (debug) System.out.println(spt);
- spt = sph;
- if (debug) System.out.println(spt);
- assertTrue( myequal(spt.x(),sph.x()) ||
- myequal(spt.y(),sph.y()) ||
- myequal(spt.z(),sph.z()) );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test cos and sin returns.");
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ));
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ));
- assertTrue( myequal( spt.cosTheta(), Math.cos( spt.theta() ) ));
- assertTrue( myequal( spt.sinTheta(), Math.sin( spt.theta() ) ));
-
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test equality.");
- CartesianPoint spt2 = new CartesianPoint(spt.x(),spt.y(),spt.z());
- assertTrue( spt.equals(spt2));
- assertTrue( !spt.notEquals(spt2) );
- if (debug) System.out.println(" spt = spt2" );
- CartesianPoint spt3 = new CartesianPoint(spt.x()+0.1,spt.y(),spt.z());
- assertTrue( spt.notEquals(spt3) );
- assertTrue( !spt.equals(spt3) );
- if (debug) System.out.println(" spt != spt3" );
- CartesianPoint spt4 = new CartesianPoint(spt.x(),spt.y()+0.2,spt.z());
- assertTrue( spt.notEquals(spt4));
- if (debug) System.out.println(" spt != spt4" );
- CartesianPoint spt5 = new CartesianPoint(spt.x(),spt.y(),spt.z()+0.3);
- assertTrue( spt.notEquals(spt5));
- if (debug) System.out.println(" spt != spt5" );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test distance function.");
- assertTrue( SpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dz = 3.3;
- double dist0 = Math.sqrt(dx*dx+dy*dy+dz*dz);
- CartesianPoint cart2 = new CartesianPoint(x+dx,y+dy,z+dz);
- if (debug) System.out.println(cart2);
- double dist = SpacePoint.distance(cart,cart2);
- if (debug) System.out.println("Distance = " + dist0 + " " + dist);
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------");
- }
-}
-
-
lcsim/test/org/lcsim/spacegeom
diff -N CylindricalPointVectorTest.java
--- CylindricalPointVectorTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,142 +0,0 @@
-package org.lcsim.spacegeom;
-// SpacePointVecTest.cpp
-
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPointVector;
-import org.lcsim.spacegeom.CylindricalPointVector;
-import org.lcsim.spacegeom.SpacePointVector;
-import org.lcsim.spacegeom.SphericalPointVector;
-
-// Test the SpacePointVector class.
-
-public class CylindricalPointVectorTest extends TestCase
-{
- boolean debug = false;
- //**********************************************************************
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-10;
- }
-
- //**********************************************************************
-
- public void testCylindricalPoint()
- {
-
- String name = "CylindricalPointVector";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- double vx = 0.23;
- double vy = 0.45;
- double vz = 0.67;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a spacevector
- CartesianPointVector cart = new CartesianPointVector(x,y,z,vx,vy,vz);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl = new CylindricalPointVector( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
- cart.v_rxy(), cart.v_phi(), cart.v_z() );
- if (debug) System.out.println( cyl );
-
- // Create in spherical coordinates.
- SphericalPointVector sph = new SphericalPointVector( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
- cyl.v_rxyz(), cyl.v_theta(), cyl.v_phi() );
- if (debug) 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.v_x(),vx) );
- assertTrue( myequal(sph.v_y(),vy) );
- assertTrue( myequal(sph.v_z(),vz) );
-
- // Create a cartesian coordinates from spacepoint
- CartesianPointVector cart2 = new CartesianPointVector( sph.getStartPoint(), sph.v_x(), sph.v_y(), sph.v_z() );
- if (debug) System.out.println( cart2 );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl2 = new CylindricalPointVector( cart2.getStartPoint(),
- cart2.v_rxy(), cart2.v_phi(), cart2.v_z() );
- if (debug) System.out.println( cyl2 );
-
- // Create in spherical coordinates.
- SphericalPointVector sph2 = new SphericalPointVector( cyl2.getStartPoint(),
- cyl2.v_rxyz(), cyl2.v_theta(), cyl2.v_phi() );
- if (debug) System.out.println( sph2 );
-
- assertTrue( myequal(sph2.getStartPoint().x(),x) );
- assertTrue( myequal(sph2.getStartPoint().y(),y) );
- assertTrue( myequal(sph2.getStartPoint().z(),z) );
- assertTrue( myequal(sph2.v_x(),vx) );
- assertTrue( myequal(sph2.v_y(),vy) );
- assertTrue( myequal(sph2.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing equality." );
- assertTrue( sph.equals(sph) );
- assertTrue( sph.equals(sph2) );
- if( sph.notEquals(sph2) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- SpacePointVector svec = new SpacePointVector();
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.magnitude() and 0 " + svec.magnitude() + " " + 0. );
- if (debug) System.out.println( "spacepoint equal " + (svec.magnitude()==0.0) );
- // Assert.assertTrue( SpacePoint.equal(svec.magnitude(),0.0) );
- svec = sph;
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.x() and x " + svec.getStartPoint().x() + " " + x );
- assertTrue( myequal(svec.getStartPoint().x(),x) );
- assertTrue( myequal(svec.getStartPoint().y(),y) );
- assertTrue( myequal(svec.getStartPoint().z(),z) );
- assertTrue( myequal(svec.v_x(),vx) );
- assertTrue( myequal(svec.v_y(),vy) );
- assertTrue( myequal(svec.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = vx*vx + vy*vy + vz*vz;
- if (debug) System.out.println( "n0= " +n0 );
- double ncart = svec.v_x()*svec.v_x() +
- svec.v_y()*svec.v_y() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncart= " +ncart );
- double ncyl = svec.v_rxy()*svec.v_rxy() +
- // FIXME this isn't supposed to be here svec.v_phi()*svec.v_phi() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncyl= " +ncyl );
- double nsph = svec.v_rxyz()*svec.v_rxyz();
- // FIXME this shouldn't have worked before + svec.v_theta()*svec.v_theta() + svec.v_phi()*svec.v_phi();
- if (debug) System.out.println( "nsph= " +nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), svec.magnitude() ) );
- //
- if (debug) System.out.println("Testing copy constructor and clone");
- SpacePointVector spv = (SpacePointVector) svec.clone();
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
- }
-
-}
\ No newline at end of file
lcsim/test/org/lcsim/spacegeom
diff -N CylindricalTwoPointTest.java
--- CylindricalTwoPointTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-package org.lcsim.spacegeom;
-//package spacegeom;
-// Test the spacepoint class.
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianTwoPoint;
-import org.lcsim.spacegeom.CylindricalTwoPoint;
-import org.lcsim.spacegeom.TwoSpacePoint;
-
-
-public class CylindricalTwoPointTest extends TestCase
-{
- boolean debug = false;
- private static boolean myequal(double x1, double x2)
- {
- return (Math.abs(x2-x1) < 1.e-12);
- }
-
- //**********************************************************************
-
- public void testCylindricalTest()
- {
-
- String name = "CylindricalTwoPoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space point
- CartesianTwoPoint cart = new CartesianTwoPoint(x,y);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalTwoPoint cyl = new CylindricalTwoPoint( cart.rxy(), cart.phi() );
- if (debug) System.out.println( cyl );
-
- if ( ! myequal(cyl.x(),x) || ! myequal(cyl.y(),y) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- TwoSpacePoint spt = new TwoSpacePoint();
- if (debug) System.out.println( spt );
- spt = cyl;
- if (debug) System.out.println( spt );
- if ( ! myequal(spt.x(),cyl.x()) || ! myequal(spt.y(),cyl.y()) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test cos and sin returns." );
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ) );
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test equality." );
- CartesianTwoPoint spt2 = new CartesianTwoPoint(spt.x(),spt.y());
- assertTrue( spt.equals(spt2) );
- assertTrue( ! (spt.notEquals(spt2)) );
- CartesianTwoPoint spt3 = new CartesianTwoPoint(spt.x()+0.1,spt.y());
- assertTrue( ! (spt.equals(spt3)) );
- assertTrue( spt.notEquals(spt3) );
- CartesianTwoPoint spt4 = new CartesianTwoPoint(spt.x(),spt.y()+0.2);
- assertTrue( spt.notEquals(spt4) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test distance function." );
- assertTrue( TwoSpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dist0 = Math.sqrt(dx*dx+dy*dy);
- CartesianTwoPoint cart2 = new CartesianTwoPoint(x+dx,y+dy);
- if (debug) System.out.println( cart );
- if (debug) System.out.println( cart2 );
- double dist = TwoSpacePoint.distance(cart,cart2);
- if (debug) System.out.println( "Distance = " + dist0 + " " + dist );
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N SpacePathTest.java
--- SpacePathTest.java 7 Sep 2005 01:09:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-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
-{
- boolean debug = false;
- //**********************************************************************
-
- 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): ";
-
- if (debug) 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;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space path element
- CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
- if (debug) 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() );
- if (debug) 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() );
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
-
- SpacePath dpth = new SpacePath();
- if (debug) System.out.println( dpth );
- assertTrue( dpth.magnitude() == 0.0 );
- dpth = sph;
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = dx*dx + dy*dy + dz*dz;
- if (debug) System.out.println( n0 );
- double ncart = dpth.dx()*dpth.dx() +
- dpth.dy()*dpth.dy() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncart );
- double ncyl = dpth.drxy()*dpth.drxy() +
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncyl );
- double nsph = dpth.drxyz()*dpth.drxyz();
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
- // FIXME dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
- if (debug) System.out.println( nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N SpacePointTest.java
--- SpacePointTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CylindricalPoint;
-import org.lcsim.spacegeom.SphericalPoint;
-
-import org.lcsim.spacegeom.SpacePoint;
-
-public class SpacePointTest extends TestCase {
-boolean debug = false;
-// SpacePointTest.java
-
-// Test the SpacePoint class.
-
-public static boolean myequal(double x1, double x2) {
- return Math.abs(x2-x1) < 1.e-12;
-}
-
-//**********************************************************************
-
- public void testSpacePoint() {
-
- String name = "SpacePoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
- if (debug) System.out.println(" ----- Testing component " + name + ". -------");
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
-//**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Testing constructors.");
- // Create a space point
- CartesianPoint cart = new CartesianPoint(x,y,z);
- if (debug) System.out.println(cart);
-
- // Create in cylindrical coordinates.
- CylindricalPoint cyl = new CylindricalPoint( cart.rxy(), cart.phi(), cart.z() );
- if (debug) System.out.println(cyl);
-
- // Create in spherical coordinates.
- SphericalPoint sph = new SphericalPoint( cyl.rxyz(), cyl.phi(), cyl.theta() );
- if (debug) System.out.println(sph);
-
- assertTrue( myequal(sph.x(),x) ||
- myequal(sph.y(),y) ||
- myequal(sph.z(),z) );
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment.");
- SpacePoint spt = new SpacePoint();
- if (debug) System.out.println(spt);
- spt = sph;
- if (debug) System.out.println(spt);
- assertTrue( myequal(spt.x(),sph.x()) ||
- myequal(spt.y(),sph.y()) ||
- myequal(spt.z(),sph.z()) );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test cos and sin returns.");
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ));
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ));
- assertTrue( myequal( spt.cosTheta(), Math.cos( spt.theta() ) ));
- assertTrue( myequal( spt.sinTheta(), Math.sin( spt.theta() ) ));
-
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test equality.");
- CartesianPoint spt2 = new CartesianPoint(spt.x(),spt.y(),spt.z());
- assertTrue( spt.equals(spt2));
- assertTrue( !spt.notEquals(spt2) );
- if (debug) System.out.println(" spt = spt2" );
- CartesianPoint spt3 = new CartesianPoint(spt.x()+0.1,spt.y(),spt.z());
- assertTrue( spt.notEquals(spt3) );
- assertTrue( !spt.equals(spt3) );
- if (debug) System.out.println(" spt != spt3" );
- CartesianPoint spt4 = new CartesianPoint(spt.x(),spt.y()+0.2,spt.z());
- assertTrue( spt.notEquals(spt4));
- if (debug) System.out.println(" spt != spt4" );
- CartesianPoint spt5 = new CartesianPoint(spt.x(),spt.y(),spt.z()+0.3);
- assertTrue( spt.notEquals(spt5));
- if (debug) System.out.println(" spt != spt5" );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test distance function.");
- assertTrue( SpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dz = 3.3;
- double dist0 = Math.sqrt(dx*dx+dy*dy+dz*dz);
- CartesianPoint cart2 = new CartesianPoint(x+dx,y+dy,z+dz);
- if (debug) System.out.println(cart2);
- double dist = SpacePoint.distance(cart,cart2);
- if (debug) System.out.println("Distance = " + dist0 + " " + dist);
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------");
- }
-}
-
-
-
\ No newline at end of file
lcsim/test/org/lcsim/spacegeom
diff -N SpacePointVecTest.java
--- SpacePointVecTest.java 7 Sep 2005 01:09:55 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPointVector;
-import org.lcsim.spacegeom.CylindricalPointVector;
-import org.lcsim.spacegeom.SpacePointVector;
-import org.lcsim.spacegeom.SphericalPointVector;
-// SpacePointVecTest.cpp
-
-// Test the SpacePointVector class.
-
-public class SpacePointVecTest extends TestCase
-{
- boolean debug = false;
- //**********************************************************************
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-10;
- }
-
- //**********************************************************************
-
- public void testSpacePointVec()
- {
-
- String name = "SpacePointVector";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- double vx = 0.23;
- double vy = 0.45;
- double vz = 0.67;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a spacevector
- CartesianPointVector cart = new CartesianPointVector(x,y,z,vx,vy,vz);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl = new CylindricalPointVector( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
- cart.v_rxy(), cart.v_phi(), cart.v_z() );
- if (debug) System.out.println( cyl );
-
- // Create in spherical coordinates.
- SphericalPointVector sph = new SphericalPointVector( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
- cyl.v_rxyz(), cyl.v_theta(), cyl.v_phi() );
- if (debug) System.out.println( sph );
-
- assertTrue(myequal(sph.getStartPoint().x(),x));
- assertTrue( myequal(sph.getStartPoint().x(),x) );
- assertTrue( myequal(sph.getStartPoint().y(),y) );
- assertTrue( myequal(sph.getStartPoint().z(),z) );
- assertTrue( myequal(sph.v_x(),vx) );
- assertTrue( myequal(sph.v_y(),vy) );
- assertTrue( myequal(sph.v_z(),vz) );
-
- // Create a cartesian coordinates from spacepoint
- CartesianPointVector cart2 = new CartesianPointVector( sph.getStartPoint(), sph.v_x(), sph.v_y(), sph.v_z() );
- if (debug) System.out.println( cart2 );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl2 = new CylindricalPointVector( cart2.getStartPoint(),
- cart2.v_rxy(), cart2.v_phi(), cart2.v_z() );
- if (debug) System.out.println( cyl2 );
-
- // Create in spherical coordinates.
- SphericalPointVector sph2 = new SphericalPointVector( cyl2.getStartPoint(),
- cyl2.v_rxyz(), cyl2.v_theta(), cyl2.v_phi() );
- if (debug) System.out.println( sph2 );
-
- assertTrue( myequal(sph2.getStartPoint().x(),x) );
- assertTrue( myequal(sph2.getStartPoint().y(),y) );
- assertTrue( myequal(sph2.getStartPoint().z(),z) );
- assertTrue( myequal(sph2.v_x(),vx) );
- assertTrue( myequal(sph2.v_y(),vy) );
- assertTrue( myequal(sph2.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing equality." );
- assertTrue( sph.equals(sph) );
- assertTrue( sph.equals(sph2) );
- if( sph.notEquals(sph2) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- SpacePointVector svec = new SpacePointVector();
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.magnitude() and 0 " + svec.magnitude() + " " + 0. );
- if (debug) System.out.println( "spacepoint equal " + (svec.magnitude()==0.0) );
- // Assert.assertTrue( SpacePoint.equal(svec.magnitude(),0.0) );
- svec = sph;
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.x() and x " + svec.getStartPoint().x() + " " + x );
- assertTrue( myequal(svec.getStartPoint().x(),x) );
- assertTrue( myequal(svec.getStartPoint().y(),y) );
- assertTrue( myequal(svec.getStartPoint().z(),z) );
- assertTrue( myequal(svec.v_x(),vx) );
- assertTrue( myequal(svec.v_y(),vy) );
- assertTrue( myequal(svec.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = vx*vx + vy*vy + vz*vz;
- if (debug) System.out.println( "n0= " +n0 );
- double ncart = svec.v_x()*svec.v_x() +
- svec.v_y()*svec.v_y() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncart= " +ncart );
- double ncyl = svec.v_rxy()*svec.v_rxy() +
- //FIXME this better didn't work until now. svec.v_phi()*svec.v_phi() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncyl= " +ncyl );
- double nsph = svec.v_rxyz()*svec.v_rxyz();
- // FIXME Norman, please take a look at the Fixmes here
- // FIXME this shouldn't have worked before + svec.v_theta()*svec.v_theta() + svec.v_phi()*svec.v_phi();
- if (debug) System.out.println( "nsph= " +nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), svec.magnitude() ) );
- //
- if (debug) System.out.println("Testing copy constructor and clone");
- SpacePointVector spv = (SpacePointVector) svec.clone();
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
- }
-
-}
\ No newline at end of file
lcsim/test/org/lcsim/spacegeom
diff -N SpacePointVectorTest.java
--- SpacePointVectorTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-package org.lcsim.spacegeom;
-
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-import junit.framework.TestCase;
-
-public class SpacePointVectorTest extends TestCase {
- boolean debug = false;
- public static boolean myEqual(Hep3Vector x1, Hep3Vector x2)
- {
- return VecOp.sub(x1, x2).magnitude() < 1.e-10;
- }
-
- private SpacePointVector thisPath;
- protected void setUp() throws Exception {
- super.setUp();
- thisPath = new SpacePointVector(new SpacePoint(), new CartesianPoint(1, 1, 1));
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /*
- * Test method for 'org.lcsim.spacegeom.SpacePath.getPointAtLength(double)'
- */
- public void testGetPointAtLength() {
- if (debug) {
- System.out.printf("To be equal: %s and %s\n\n", thisPath.getPointAtLength(0), thisPath.getStartPoint());
- }
- assertTrue(myEqual(thisPath.getPointAtLength(0), thisPath.getStartPoint()));
- if (debug) {
- System.out.printf("To be equal: %s and %s\n\n", thisPath.getPointAtLength(1), thisPath.getEndPoint());
- }
- assertTrue(myEqual(thisPath.getPointAtLength(1), thisPath.getEndPoint()));
- assertFalse(thisPath.getPointAtLength(1).equals(thisPath.getStartPoint()));
- SpacePoint farPoint = new CartesianPoint(2, 2, 2);
- assertTrue(thisPath.getPointAtLength(2).equals(farPoint));
- SpacePoint halfPoint = new CartesianPoint(0.5, 0.5, 0.5);
- assertTrue(thisPath.getPointAtLength(0.5).equals(halfPoint));
- SpacePoint negPoint = new CartesianPoint(-1, -1, -1);
- assertTrue(thisPath.getPointAtLength(-1).equals(negPoint));
- }
-
-}
lcsim/test/org/lcsim/spacegeom
diff -N SpaceXformTest.java
--- SpaceXformTest.java 9 Aug 2007 00:03:53 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,61 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-// Test the SpaceXform class.
-
-//**********************************************************************
-public class SpaceXformTest extends TestCase
-{
- static class TestXform extends SpaceXform
- {
- public static int _check = 0;
- public SpaceXform inverse()
- { return this; }
- public SpacePoint apply( SpacePoint spt)
- { _check=1; return spt; }
- public SpacePointVector apply( SpacePointVector svec)
- { _check=2; return svec; }
- }
-
- //**********************************************************************
- boolean debug = false;
-
- public void testSpaceXForm()
- {
-
- String name = "SpaceXform";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructor." );
- TestXform xf = new TestXform();
-
- SpacePoint spt1 = new SpacePoint();
- SpacePointVector svec1 = new SpacePointVector();
- SpacePath spth1 = new SpacePath();
-
- assertTrue(xf._check == 0);
- SpacePoint spt2 = xf.transform(spt1);
- assertTrue(xf._check == 1);
-
- SpacePointVector svec2 = xf.transform(svec1);
- assertTrue(xf._check == 2);
-
- SpacePointVector spth2 = xf.transform(spth1);
- assertTrue(xf._check == 2);
- spt2.x();
- svec2.getStartPoint().x();
- spth2.getStartPoint().x();
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N SphericalPathTest.java
--- SphericalPathTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-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
-{
- //**********************************************************************
- boolean debug = false;
- 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): ";
-
- if (debug) 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;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space path element
- CartesianPath cart = new CartesianPath(x,y,z,dx,dy,dz);
- if (debug) 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() );
- if (debug) 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() );
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
-
- SpacePath dpth = new SpacePath();
- if (debug) System.out.println( dpth );
- assertTrue( dpth.magnitude() == 0.0 );
- dpth = sph;
- if (debug) 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) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = dx*dx + dy*dy + dz*dz;
- if (debug) System.out.println( n0 );
- double ncart = dpth.dx()*dpth.dx() +
- dpth.dy()*dpth.dy() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncart );
- double ncyl = dpth.drxy()*dpth.drxy() +
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() +
- dpth.dz()*dpth.dz();
- if (debug) System.out.println( ncyl );
- double nsph = dpth.drxyz()*dpth.drxyz();
- // FIXME dpth.rxy_dphi()*dpth.rxy_dphi() + dpth.rxyz_dtheta()*dpth.rxyz_dtheta();
- if (debug) System.out.println( nsph );
- assertTrue( myequal(ncart,n0) );
- assertTrue( myequal(ncyl,n0) );
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), dpth.magnitude() ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
lcsim/test/org/lcsim/spacegeom
diff -N SphericalPointTest.java
--- SphericalPointTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-package org.lcsim.spacegeom;
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CylindricalPoint;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SphericalPoint;
-
-public class SphericalPointTest extends TestCase
-{
- boolean debug = false;
- // SpacePointTest.java
-
- // Test the SpacePoint class.
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-12;
- }
-
- //**********************************************************************
-
- public void testSphericalPoint()
- {
-
- String name = "SphericalPoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
- if (debug) System.out.println(" ----- Testing component " + name + ". -------");
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Testing constructors.");
- // Create a space point
- CartesianPoint cart = new CartesianPoint(x,y,z);
- if (debug) System.out.println(cart);
-
- // Create in cylindrical coordinates.
- CylindricalPoint cyl = new CylindricalPoint( cart.rxy(), cart.phi(), cart.z() );
- if (debug) System.out.println(cyl);
-
- // Create in spherical coordinates.
- SphericalPoint sph = new SphericalPoint( cyl.rxyz(), cyl.phi(), cyl.theta() );
- if (debug) System.out.println(sph);
-
- assertTrue( myequal(sph.x(),x) ||
- myequal(sph.y(),y) ||
- myequal(sph.z(),z) );
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment.");
- SpacePoint spt = new SpacePoint();
- if (debug) System.out.println(spt);
- spt = sph;
- if (debug) System.out.println(spt);
- assertTrue( myequal(spt.x(),sph.x()) ||
- myequal(spt.y(),sph.y()) ||
- myequal(spt.z(),sph.z()) );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test cos and sin returns.");
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ));
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ));
- assertTrue( myequal( spt.cosTheta(), Math.cos( spt.theta() ) ));
- assertTrue( myequal( spt.sinTheta(), Math.sin( spt.theta() ) ));
-
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test equality.");
- CartesianPoint spt2 = new CartesianPoint(spt.x(),spt.y(),spt.z());
- assertTrue( spt.equals(spt2));
- assertTrue( !spt.notEquals(spt2) );
- if (debug) System.out.println(" spt = spt2" );
- CartesianPoint spt3 = new CartesianPoint(spt.x()+0.1,spt.y(),spt.z());
- assertTrue( spt.notEquals(spt3) );
- assertTrue( !spt.equals(spt3) );
- if (debug) System.out.println(" spt != spt3" );
- CartesianPoint spt4 = new CartesianPoint(spt.x(),spt.y()+0.2,spt.z());
- assertTrue( spt.notEquals(spt4));
- if (debug) System.out.println(" spt != spt4" );
- CartesianPoint spt5 = new CartesianPoint(spt.x(),spt.y(),spt.z()+0.3);
- assertTrue( spt.notEquals(spt5));
- if (debug) System.out.println(" spt != spt5" );
- //**********************************************************************
-
- if (debug) System.out.println(ok_prefix + "Test distance function.");
- assertTrue( SpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dz = 3.3;
- double dist0 = Math.sqrt(dx*dx+dy*dy+dz*dz);
- CartesianPoint cart2 = new CartesianPoint(x+dx,y+dy,z+dz);
- if (debug) System.out.println(cart2);
- double dist = SpacePoint.distance(cart,cart2);
- if (debug) System.out.println("Distance = " + dist0 + " " + dist);
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------");
- }
-}
-
-
lcsim/test/org/lcsim/spacegeom
diff -N SphericalPointVectorTest.java
--- SphericalPointVectorTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,145 +0,0 @@
-package org.lcsim.spacegeom;
-// SpacePointVecTest.cpp
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianPointVector;
-import org.lcsim.spacegeom.CylindricalPointVector;
-import org.lcsim.spacegeom.SpacePointVector;
-import org.lcsim.spacegeom.SphericalPointVector;
-
-// Test the SpacePointVector class.
-
-public class SphericalPointVectorTest extends TestCase
-{
- boolean debug = false;
- //**********************************************************************
-
- public static boolean myequal(double x1, double x2)
- {
- return Math.abs(x2-x1) < 1.e-10;
- }
-
- //**********************************************************************
-
- public void testSphericalPointVector()
- {
-
- String name = "SphericalPointVector";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
- double z = 3.69;
- double vx = 0.23;
- double vy = 0.45;
- double vz = 0.67;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a spacevector
- CartesianPointVector cart = new CartesianPointVector(x,y,z,vx,vy,vz);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- // FIXME adjust for new definition of class. Needs to be done throughout the class
- CylindricalPointVector cyl = new CylindricalPointVector( cart.getStartPoint().rxy(), cart.getStartPoint().phi(), cart.getStartPoint().z(),
- cart.v_rxy(), cart.v_phi(), cart.v_z() );
- if (debug) System.out.println( cyl );
-
- // Create in spherical coordinates.
- // FIXME adjust for new definition of class
- SphericalPointVector sph = new SphericalPointVector( cyl.getStartPoint().rxyz(), cyl.getStartPoint().phi(), cyl.getStartPoint().theta(),
- cyl.v_rxyz(), cyl.v_theta(), cyl.v_phi() );
- if (debug) 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.v_x(),vx) );
- assertTrue( myequal(sph.v_y(),vy) );
- assertTrue( myequal(sph.v_z(),vz) );
-
- // Create a cartesian coordinates from spacepoint
- CartesianPointVector cart2 = new CartesianPointVector( sph.getStartPoint(), sph.v_x(), sph.v_y(), sph.v_z() );
- if (debug) System.out.println( cart2 );
-
- // Create in cylindrical coordinates.
- CylindricalPointVector cyl2 = new CylindricalPointVector( cart2.getStartPoint(),
- cart2.v_rxy(), cart2.v_phi(), cart2.v_z() );
- if (debug) System.out.println( cyl2 );
-
- // Create in spherical coordinates.
- SphericalPointVector sph2 = new SphericalPointVector( cyl2.getStartPoint(),
- cyl2.v_rxyz(), cyl2.v_theta(), cyl2.v_phi() );
- if (debug) System.out.println( sph2 );
-
- assertTrue( myequal(sph2.getStartPoint().x(),x) );
- assertTrue( myequal(sph2.getStartPoint().y(),y) );
- assertTrue( myequal(sph2.getStartPoint().z(),z) );
- assertTrue( myequal(sph2.v_x(),vx) );
- assertTrue( myequal(sph2.v_y(),vy) );
- assertTrue( myequal(sph2.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing equality." );
- assertTrue( sph.equals(sph) );
- assertTrue( sph.equals(sph2) );
- if( sph.notEquals(sph2) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- SpacePointVector svec = new SpacePointVector();
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.magnitude() and 0 " + svec.magnitude() + " " + 0. );
- if (debug) System.out.println( "spacepoint equal " + (svec.magnitude()==0.0) );
- // Assert.assertTrue( SpacePoint.equal(svec.magnitude(),0.0) );
- svec = sph;
- if (debug) System.out.println( svec );
- if (debug) System.out.println( "testing assignment svec.x() and x " + svec.getStartPoint().x() + " " + x );
- assertTrue( myequal(svec.getStartPoint().x(),x) );
- assertTrue( myequal(svec.getStartPoint().y(),y) );
- assertTrue( myequal(svec.getStartPoint().z(),z) );
- assertTrue( myequal(svec.v_x(),vx) );
- assertTrue( myequal(svec.v_y(),vy) );
- assertTrue( myequal(svec.v_z(),vz) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing normalizations." );
- double n0 = vx*vx + vy*vy + vz*vz;
- if (debug) System.out.println( "n0= " +n0 );
- double ncart = svec.v_x()*svec.v_x() +
- svec.v_y()*svec.v_y() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncart= " +ncart );
- double ncyl = svec.v_rxy()*svec.v_rxy() +
- // FIXME or not... svec.v_phi()*svec.v_phi() +
- svec.v_z()*svec.v_z();
- if (debug) System.out.println( "ncyl= " +ncyl );
- double nsph = svec.v_rxyz()*svec.v_rxyz();
- // FIXME not really + svec.v_theta()*svec.v_theta() + svec.v_phi()*svec.v_phi();
- if (debug) System.out.println( "nsph= " +nsph );
- assertTrue( myequal(ncart,n0) );
- // FIXME I hope this never really passed
- assertTrue( myequal(ncyl,n0) );
- // FIXME This isn't supposed to pass, either, is it ?
- assertTrue( myequal(nsph,n0) );
- assertTrue( myequal( Math.sqrt(n0), svec.magnitude() ) );
- //
- if (debug) System.out.println("Testing copy constructor and clone");
- SpacePointVector spv = (SpacePointVector) svec.clone();
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
- }
-
-}
\ No newline at end of file
lcsim/test/org/lcsim/spacegeom
diff -N TwoSegmentTest.java
--- TwoSegmentTest.java 7 Sep 2005 01:09:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-package org.lcsim.spacegeom;
-// Test the TwoSegment class.
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianTwoPoint;
-import org.lcsim.spacegeom.TwoSegment;
-import org.lcsim.spacegeom.TwoSpacePoint;
-
-public class TwoSegmentTest extends TestCase
-{
- boolean debug = false;
- public void testTwoSegmentTest()
- {
-
- String name = "TwoSegment";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
-
- TwoSpacePoint a = new CartesianTwoPoint(1.,1.);
- TwoSpacePoint b = new CartesianTwoPoint(2.,2.);
- TwoSegment seg = new TwoSegment(a,b);
-
- if (debug) System.out.println(seg);
-
- assertTrue(a.equals(seg.startPoint()));
- assertTrue(b.equals(seg.endPoint()));
-
- assertTrue(seg.length()==TwoSpacePoint.distance(a,b));
-
-
- if (debug) System.out.println( ok_prefix + "Testing intersection." );
- TwoSegment seg2 = new TwoSegment(a,b);
-
- assertTrue(TwoSegment.intersection(seg,seg2)==null);
-
- TwoSegment seg3 = new TwoSegment(new CartesianTwoPoint(-1.,-1.),new CartesianTwoPoint(1.,1.));
- TwoSegment seg4 = new TwoSegment(new CartesianTwoPoint(-1.,1.),new CartesianTwoPoint(1.,-1.));
-
- TwoSpacePoint intersection = TwoSegment.intersection(seg3, seg4);
- if (debug) System.out.println(intersection);
- assertTrue(intersection.x()==0.);
- assertTrue(intersection.y()==0.);
-
-
- // try another...
- TwoSegment t1 = new TwoSegment(new CartesianTwoPoint(0.25, 0), new CartesianTwoPoint(1.25, 2.0));
- TwoSegment t2 = new TwoSegment(new CartesianTwoPoint(0.05, 0), new CartesianTwoPoint(-0.947, 2.0));
- intersection = TwoSegment.intersection(t1, t2);
- if (debug) System.out.println(intersection);
-
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-
-}
lcsim/test/org/lcsim/spacegeom
diff -N TwoSpacePointTest.java
--- TwoSpacePointTest.java 7 Sep 2005 01:09:55 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-package org.lcsim.spacegeom;
-// Test the spacepoint class.
-import junit.framework.TestCase;
-
-import org.lcsim.spacegeom.CartesianTwoPoint;
-import org.lcsim.spacegeom.CylindricalTwoPoint;
-import org.lcsim.spacegeom.TwoSpacePoint;
-
-public class TwoSpacePointTest extends TestCase
-{
- boolean debug = false;
- private static boolean myequal(double x1, double x2)
- {
- return (Math.abs(x2-x1) < 1.e-12);
- }
-
- //**********************************************************************
-
- public void testTwoSpacePoint()
- {
-
- String name = "TwoSpacePoint";
- String ok_prefix = name + " test (I): ";
- String error_prefix = name + " test (E): ";
-
- if (debug) System.out.println( ok_prefix
- + "------- Testing component " + name + ". -------" );
-
- double x = 1.23;
- double y = 2.46;
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing constructors." );
- // Create a space point
- CartesianTwoPoint cart = new CartesianTwoPoint(x,y);
- if (debug) System.out.println( cart );
-
- // Create in cylindrical coordinates.
- CylindricalTwoPoint cyl = new CylindricalTwoPoint( cart.rxy(), cart.phi() );
- if (debug) System.out.println( cyl );
-
- if ( ! myequal(cyl.x(),x) || ! myequal(cyl.y(),y) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Testing assignment." );
- TwoSpacePoint spt = new TwoSpacePoint();
- if (debug) System.out.println( spt );
- spt = cyl;
- if (debug) System.out.println( spt );
- if ( ! myequal(spt.x(),cyl.x()) || ! myequal(spt.y(),cyl.y()) )
- {
- if (debug) System.out.println( error_prefix + "Mismatch." );
- System.exit(1);
- }
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test cos and sin returns." );
- assertTrue( myequal( spt.cosPhi(), Math.cos( spt.phi() ) ) );
- assertTrue( myequal( spt.sinPhi(), Math.sin( spt.phi() ) ) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test equality." );
- CartesianTwoPoint spt2 = new CartesianTwoPoint(spt.x(),spt.y());
- assertTrue( spt.equals(spt2) );
- assertTrue( ! (spt.notEquals(spt2)) );
- CartesianTwoPoint spt3 = new CartesianTwoPoint(spt.x()+0.1,spt.y());
- assertTrue( ! (spt.equals(spt3)) );
- assertTrue( spt.notEquals(spt3) );
- CartesianTwoPoint spt4 = new CartesianTwoPoint(spt.x(),spt.y()+0.2);
- assertTrue( spt.notEquals(spt4) );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix + "Test distance function." );
- assertTrue( TwoSpacePoint.distance(cart,cart) == 0.0 );
- double dx = 1.1;
- double dy = 2.2;
- double dist0 = Math.sqrt(dx*dx+dy*dy);
- CartesianTwoPoint cart2 = new CartesianTwoPoint(x+dx,y+dy);
- if (debug) System.out.println( cart );
- if (debug) System.out.println( cart2 );
- double dist = TwoSpacePoint.distance(cart,cart2);
- if (debug) System.out.println( "Distance = " + dist0 + " " + dist );
- assertTrue( Math.abs( dist - dist0 ) < 1.e-12 );
-
- //**********************************************************************
-
- if (debug) System.out.println( ok_prefix
- + "------------- All tests passed. ------------" );
-
- }
-}
CVSspam 0.2.8