def testPolygonInsideAnother(self): figure = Prism.from_points_xy( array([[ 7.69945323, 7.69945323, 10.97806236, 11.42204982, 8.47089291 ], [ 54.13234479, 54.13234479, 55.86027265, 54.38893454, 52.75711988 ]]), 0.85000741680000036, 1.8500074168000005) landmark = Prism.from_points_xy( array([[8.20976285, 7.35040178, 12.13996339, 12.99932446], [52.3373722, 54.04890265, 56.4537461, 54.74221565]]), 0.44360731519999963, 0.8500074167999998) self.assertEqual(math2d_overlaps(figure.points_xy, landmark.points_xy), True) self.assertEqual(math2d_overlaps(landmark.points_xy, figure.points_xy), True) self.assertEqual(math3d_higher_than(figure, landmark), True) self.assertEqual(math3d_higher_than(landmark, figure), False) self.assertEqual(math3d_supports(figure, landmark), False) self.assertEqual(math3d_supports(landmark, figure), True) names = sfe_f_prism_l_prism_names() feats_obs = sfe_f_prism_l_prism(figure, landmark, normalize=True) features = dict(zip(names, feats_obs)) self.assertEqual(features["F_3dSupportsLandmarkFigure"], 1) self.assertEqual(features["F_3dSupportsFigureLandmark"], 0)
def testPrism(self): prism1 = Prism.from_points_xy(tp([(0, 0), (1, 0), (1, 1), (0, 1)]), zStart=0, zEnd=4) prism2 = Prism.from_points_xy(tp([(0, 0), (1, 0), (1, 1), (0, 1)]), zStart=4.1, zEnd=5) self.assertEqual(math3d_higher_than(prism2, prism2), False) self.assertEqual(math3d_higher_than(prism1, prism1), False) self.assertEqual(math3d_higher_than(prism1, prism2), False) self.assertEqual(math3d_higher_than(prism2, prism1), True) self.assertEqual(math2d_overlaps(prism1.points_xy, prism2.points_xy), True) self.assertEqual(math2d_overlaps(prism2.points_xy, prism1.points_xy), True) #print "points", prism1.points_xy #print "points", prism1.points_xy[0] features = sfe_f_prism_l_prism(prism1, prism2, normalize=True) fnames = list(sfe_f_prism_l_prism_names()) self.assertEqual(len(fnames), len(features)) print fnames print features fmap = dict(zip(fnames, features)) self.assertEqual(fmap['F_3dEndsHigherThanFigureLandmark'], 0) self.assertEqual(fmap['F_3dEndsHigherThanLandmarkFigure'], 1) self.assertEqual(fmap['F_3dSupportsFigureLandmark'], 1) self.assertEqual(fmap['F_3dSupportsLandmarkFigure'], 0)
def testNotOverlapping(self): fend = Prism.from_points_xy( array([[11.38086607, 11.11520079, 10.6916185, 10.95728378], [50.18213065, 50.60571294, 50.34004767, 49.91646537]]), 0.0, 2.0) lend = Prism.from_points_xy( array([[8.81022941, 8.31022943, 9.34945991, 9.8494599], [52.6054371, 53.47146252, 54.07146249, 53.20543707]]), 0.81463427695147927, 1.5180196621514792) features = compute_fdict( sfe_f_prism_l_prism_names(), sfe_f_prism_l_prism(fend, lend, normalize=True)) self.assertEqual(math3d_higher_than(fend, lend), True) self.assertEqual(math3d_higher_than(lend, fend), False) self.assertEqual(math2d_overlaps(fend.points_xy, lend.points_xy), False) self.assertEqual(math3d_intersect_prisms(fend, fend), True) self.assertEqual(features["F_3dSupportsLandmarkFigure"], 0) self.assertEqual(features["F_3dSupportsFigureLandmark"], 0)