View Javadoc

1   package org.lcsim.spacegeom;
2   
3   import hep.physics.vec.Hep3Vector;
4   import hep.physics.vec.VecOp;
5   import junit.framework.TestCase;
6   
7   public class SpacePointVectorTest extends TestCase {
8       boolean debug = false;
9       public static boolean myEqual(Hep3Vector x1, Hep3Vector x2)
10      {
11          return VecOp.sub(x1, x2).magnitude() < 1.e-10;
12      }
13      
14      private SpacePointVector thisPath;
15      protected void setUp() throws Exception {
16          super.setUp();
17          thisPath = new SpacePointVector(new SpacePoint(), new CartesianPoint(1, 1, 1));
18      }
19  
20      protected void tearDown() throws Exception {
21          super.tearDown();
22      }
23  
24      /*
25       * Test method for 'org.lcsim.spacegeom.SpacePath.getPointAtLength(double)'
26       */
27      public void testGetPointAtLength() {
28          if (debug) {
29              System.out.printf("To be equal: %s and %s\n\n", thisPath.getPointAtLength(0), thisPath.getStartPoint());
30          }
31          assertTrue(myEqual(thisPath.getPointAtLength(0), thisPath.getStartPoint()));
32          if (debug) {
33              System.out.printf("To be equal: %s and %s\n\n", thisPath.getPointAtLength(1), thisPath.getEndPoint());
34          }
35          assertTrue(myEqual(thisPath.getPointAtLength(1), thisPath.getEndPoint()));
36          assertFalse(thisPath.getPointAtLength(1).equals(thisPath.getStartPoint()));
37          SpacePoint farPoint = new CartesianPoint(2, 2, 2);
38          assertTrue(thisPath.getPointAtLength(2).equals(farPoint));
39          SpacePoint halfPoint = new CartesianPoint(0.5, 0.5, 0.5);
40          assertTrue(thisPath.getPointAtLength(0.5).equals(halfPoint));
41          SpacePoint negPoint = new CartesianPoint(-1, -1, -1);
42          assertTrue(thisPath.getPointAtLength(-1).equals(negPoint));
43      }
44  
45  }