Example #1
0
 def test_generate_points(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertAlmostEqual(reg_shape.get_nth_point(2)[1][0], 0.0)
     self.assertAlmostEqual(reg_shape.get_nth_point(2)[1][1], 1.0)
     self.assertAlmostEqual(reg_shape.get_nth_point(3)[1][0], 1.0)
     self.assertAlmostEqual(reg_shape.get_nth_point(3)[1][1], 1.0)
     self.assertAlmostEqual(reg_shape.get_nth_point(4)[1][0], 1.0)
     self.assertAlmostEqual(reg_shape.get_nth_point(4)[1][1], 0.0)
Example #2
0
 def test_is_valid_shape(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertTrue(reg_shape.is_valid_shape())
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (2.0, 2.0)),
                              (3, (4.0, 0.0)), 4)
     self.assertTrue(reg_shape.is_valid_shape())
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 5)
     self.assertFalse(reg_shape.is_valid_shape())
Example #3
0
 def test_get_shape_area(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertEqual(reg_shape.get_area(), 1)
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (1.0, 1.0)),
                              (3, (2.0, 0.0)), 4)
     self.assertEqual(reg_shape.get_area(), 2)
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (1.0, 1.0)),
                              (3, (1.0, -1.0)), 4)
     self.assertEqual(reg_shape.get_area(), 2)
Example #4
0
 def test_point_in_shape(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertTrue(reg_shape.point_in_shape((2, (0.0, 1.0))))
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertTrue(reg_shape.point_in_shape((3, (1.0, 1.0))))
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 5)
     self.assertFalse(reg_shape.point_in_shape((3, (6.0, 6.0))))
Example #5
0
 def test_regular_shape_init(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 3)
     self.assertEqual(reg_shape.point1_expected, (1, (0.0, 0.0)))
     self.assertAlmostEqual(reg_shape.angle_ratio, math.pi / 3)
Example #6
0
 def test_match_points_id(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (4, (1.0, 1.0)), 4)
     self.assertFalse(reg_shape.is_valid_shape())
     reg_shape.match_points_id()
     self.assertTrue(reg_shape.is_valid_shape())
Example #7
0
 def test_get_nth_point(self):
     reg_shape = RegularShape((1, (0.0, 0.0)), (2, (0.0, 1.0)),
                              (3, (1.0, 1.0)), 4)
     self.assertEqual(reg_shape.get_nth_point(3), (3, (1.0, 1.0)))