예제 #1
0
 @Override
 public void testOutputs(HashMap<Variable, Double> outputs) {
   assertTrue(outputs.containsKey(new MultivectorComponent("abstand", 0)));
   assertTrue(outputs.containsKey(new MultivectorComponent("nor", 1)));
   assertTrue(outputs.containsKey(new MultivectorComponent("nor", 2)));
   assertTrue(outputs.containsKey(new MultivectorComponent("nor", 3)));
   // assertTrue(outputs.containsKey(new MultivectorComponent("", )));
   double abstand = outputs.get(new MultivectorComponent("abstand", 0));
   Vec3D nor =
       new Vec3D(
           outputs.get(new MultivectorComponent("nor", 1)),
           outputs.get(new MultivectorComponent("nor", 2)),
           outputs.get(new MultivectorComponent("nor", 3)));
   nor.normalize();
   nor.scalarMultiplication(abstand);
   Point3D pBase = nor.applyToPoint(new Point3D(pTest.x, pTest.y, pTest.z));
   // pBase must lie on plane and on line
   // test if on line, assume that dx,dy,dz not zero
   double tx = (pBase.x - p1.x) / ((p2.x - p1.x));
   double ty = (pBase.y - p1.y) / ((p2.y - p1.y));
   double tz = (pBase.z - p1.z) / ((p2.z - p1.z));
   // since the normal is unique except of a sign:
   if (Math.abs(tx - ty) > 0.001 || Math.abs(tz - ty) > 0.001) {
     nor =
         new Vec3D(
             outputs.get(new MultivectorComponent("nor", 1)),
             outputs.get(new MultivectorComponent("nor", 2)),
             outputs.get(new MultivectorComponent("nor", 3)));
     nor.normalize();
     nor.scalarMultiplication(-abstand);
     pBase = nor.applyToPoint(new Point3D(pTest.x, pTest.y, pTest.z));
     // pBase must lie on plane and on line
     // test if on line, assume that dx,dy,dz not zero
     tx = (pBase.x - p1.x) / ((p2.x - p1.x));
     ty = (pBase.y - p1.y) / ((p2.y - p1.y));
     tz = (pBase.z - p1.z) / ((p2.z - p1.z));
   }
   assertEquals(tx, ty, 0.001);
   assertEquals(ty, tz, 0.001);
   // test if on plane
   Vec3D r = new Vec3D((p2.x - p1.x), (p2.y - p1.y), (p2.z - p1.z));
   r.normalize();
   Vec3D xmpTest = new Vec3D(pBase.x - pTest.x, pBase.y - pTest.y, pBase.z - pTest.z);
   double dp = xmpTest.dotProduct(r);
   assertEquals(0, dp, 0.001);
 }