Exemple #1
0
 def test_interior_edges_tuple_non_ortho(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 1)
     p3 = IntegerPoint(1, 2)
     t1 = IntegerTriangle(p1, p2, p3)
     interiorEdges = []
     for edgeTuple in t1.interior_edges_tuple():
         interiorEdges.append(IntegerSegment(edgeTuple))
Exemple #2
0
 def test_sides(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 0)
     p3 = IntegerPoint(2, 1)
     a = IntegerSegment(p1, p2)
     b = IntegerSegment(p2, p3)
     c = IntegerSegment(p3, p1)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertTupleEqual(t1.sides(), (a, b, c))
Exemple #3
0
 def test_ortho_right_squaring_shapes(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(6, 0)
     p3 = IntegerPoint(6, 4)
     p4 = IntegerPoint(0, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     self.assertEqual(len(shapes), 1)
     expectedTriangle = IntegerOrthoRightTriangle(p1, p3, p4)
     self.assertTrue(shapes[0].like(expectedTriangle))
Exemple #4
0
 def test_common_edge_squaring_shapes_right(self):
     p1 = IntegerPoint(5, 0)
     p2 = IntegerPoint(0, 2)
     p3 = IntegerPoint(5, 4)
     p4 = IntegerPoint(0, 0)
     p5 = IntegerPoint(0, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p4)
     expectedTriangle2 = IntegerTriangle(p2, p3, p5)
     self.assertEqual(len(shapes), 2)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
Exemple #5
0
 def test_circumscribed_rectangle_non_ortho_2_pts_common_pos_slope_on_diagonal(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 2)
     p3 = IntegerPoint(5, 5)
     t1 = IntegerTriangle(p1, p2, p3)
     rp1 = IntegerPoint(0, 0)
     rp3 = IntegerPoint(5, 5)
     a = IntegerSegment(rp1, IntegerPoint(rp3._x, rp1._y))
     b = IntegerSegment(IntegerPoint(rp3._x, rp1._y), rp3)
     c = IntegerSegment(rp3, IntegerPoint(rp1._x, rp3._y))
     d = IntegerSegment(IntegerPoint(rp1._x, rp3._y), rp1)
     self.assertTupleEqual(t1.circumscribed_rectangle().sides(), (a, b, c, d))
     self.assertTupleEqual(t1.circumscribed_rectangle().vertices(), (a._p1, b._p1, c._p1, d._p1))
Exemple #6
0
 def test_circumscribed_rectangle_non_ortho_2_pts_common_neg_slope_above_diagonal(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(3, -1)
     p3 = IntegerPoint(5, -5)
     t1 = IntegerTriangle(p1, p2, p3)
     rp1 = IntegerPoint(0, -5)
     rp3 = IntegerPoint(5, 0)
     a = IntegerSegment(rp1, IntegerPoint(rp3._x, rp1._y))
     b = IntegerSegment(IntegerPoint(rp3._x, rp1._y), rp3)
     c = IntegerSegment(rp3, IntegerPoint(rp1._x, rp3._y))
     d = IntegerSegment(IntegerPoint(rp1._x, rp3._y), rp1)
     rect = t1.circumscribed_rectangle()
     self.assertTupleEqual(rect.sides(), (a, b, c, d))
     self.assertTupleEqual(rect.vertices(), (a._p1, b._p1, c._p1, d._p1))
Exemple #7
0
 def test_squaring_shapes_no_interior_vertex(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(5, 2)
     p3 = IntegerPoint(2, 5)
     p4 = IntegerPoint(5, 0)
     p5 = IntegerPoint(5, 5)
     p6 = IntegerPoint(0, 5)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p4)
     expectedTriangle2 = IntegerTriangle(p2, p3, p5)
     expectedTriangle3 = IntegerTriangle(p1, p3, p6)
     self.assertEqual(len(shapes), 3)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle3)]), 1)
Exemple #8
0
 def test_squaring_shapes_upper_right_interior_vertex(self):
     p1 = IntegerPoint(0, 5)
     p2 = IntegerPoint(4, 4)
     p3 = IntegerPoint(6, 0)
     p4 = IntegerPoint(6, 4)
     p5 = IntegerPoint(4, 5)
     p6 = IntegerPoint(0, 0)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p5)
     expectedTriangle2 = IntegerTriangle(p2, p3, p4)
     expectedTriangle3 = IntegerTriangle(p1, p3, p6)
     expectedRectangle = IntegerOrthoRectangle(p4, p5)
     self.assertEqual(len(shapes), 4)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle3)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedRectangle)]), 1)
Exemple #9
0
 def test_ortho_right_interior_pt_ct_upper_left(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(0, 4)
     p3 = IntegerPoint(6, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertEqual(t1.interior_pt_ct(), 7)
Exemple #10
0
 def test_common_edge_interior_pt_ct_right(self):
     p1 = IntegerPoint(5, 0)
     p2 = IntegerPoint(0, 2)
     p3 = IntegerPoint(5, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertEqual(t1.interior_pt_ct(), 8)
Exemple #11
0
 def test_common_edge_interior_pt_ct_bottom(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 4)
     p3 = IntegerPoint(5, 0)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertEqual(t1.interior_pt_ct(), 7)
Exemple #12
0
 def test_interior_pt_ct_lower_right_interior_vertex(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(3, 1)
     p3 = IntegerPoint(4, 5)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertEqual(t1.interior_pt_ct(), 5)
Exemple #13
0
 def test_interior_pt_ct_no_interior_vertex(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(5, 2)
     p3 = IntegerPoint(2, 5)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertEqual(t1.interior_pt_ct(), 9)
Exemple #14
0
 def test_side_tuple(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 0)
     p3 = IntegerPoint(2, 1)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertTupleEqual(t1.vertex_tuple(), ((0, 0), (2, 0), (2, 1)))
Exemple #15
0
 def test_vertices(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(2, 0)
     p3 = IntegerPoint(2, 1)
     t1 = IntegerTriangle(p1, p2, p3)
     self.assertTupleEqual(t1.vertices(), (p1, p2, p3))
Exemple #16
0
 def test_creation_from_tuple(self):
     t1 = IntegerTriangle((0, 0), (2, 0), (2, 1))
     self.assertTupleEqual(t1.vertex_tuple(), ((0, 0), (2, 0), (2, 1)))