예제 #1
0
 def test_for_rectangle_and_rectangle3(self):
     """the third test for checking if a given rectangle is located
     inside another given rectangle with them fully overlapping each
     other
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec1 = shapes.Rectangle(v1, v2, v3, v4)
     rec2 = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(rec1, rec2))
예제 #2
0
 def test_for_rectangle_and_rectangle6(self):
     """the sixth test for checking if a given rectangle is located
     inside another given rectangle with them being fully apart
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec1 = shapes.Rectangle(v1, v2, v3, v4)
     v5 = shapes.Point(8, -2)
     v6 = shapes.Point(12, -2)
     v7 = shapes.Point(12, 2)
     v8 = shapes.Point(8, 2)
     rec2 = shapes.Rectangle(v5, v6, v7, v8)
     self.assertFalse(operations.is_inside(rec1, rec2))
예제 #3
0
    def test_move(self):
        """testing if the Montmorillonite instance moves correctly with
        the given derivatives; this is inherited from the parent class
        'Particle'
        """

        particle = base_classes.Kaolinite(
            x=0,
            y=0,
            inclination=np.math.pi / 4,
            thickness=2,
            length=6000 * np.sqrt(2),
        )
        particle.move(delta_x=1000, delta_y=1000, delta_theta=np.math.pi / 4)
        self.assertEqual(particle.x, 1000)
        self.assertEqual(particle.y, 1000)
        self.assertEqual(particle.inclination, np.math.pi / 2)
        self.assertEqual(particle.midpoint, shapes.Point(1000, 1000))
        self.assertEqual(
            particle.midline,
            shapes.LineSegment(shapes.Point(1000, 1000 + 3000 * np.sqrt(2)),
                               shapes.Point(1000, 1000 - 3000 * np.sqrt(2))))
        v1 = shapes.Point(1001, 1000 + 3000 * np.sqrt(2))
        v2 = shapes.Point(999, 1000 + 3000 * np.sqrt(2))
        v3 = shapes.Point(999, 1000 - 3000 * np.sqrt(2))
        v4 = shapes.Point(1001, 1000 - 3000 * np.sqrt(2))
        self.assertEqual(particle.shape, shapes.Rectangle(v1, v2, v3, v4))
예제 #4
0
    def test_move(self):
        """testing the 'move' method of the Rectangle class
        """

        v1 = shapes.Point(np.sqrt(2), np.sqrt(2))
        v2 = shapes.Point(-1*np.sqrt(2), np.sqrt(2))
        v3 = shapes.Point(-1*np.sqrt(2), -1*np.sqrt(2))
        v4 = shapes.Point(np.sqrt(2), -1*np.sqrt(2))
        rec1 = shapes.Rectangle(v1, v2, v3, v4)
        rec1.move(delta_theta = np.math.pi/4)
        v5 = shapes.Point(2, 0)
        v6 = shapes.Point(0, 2)
        v7 = shapes.Point(-2, 0)
        v8 = shapes.Point(0, -2)
        rec2 = shapes.Rectangle(v5, v6, v7, v8)
        self.assertEqual(rec1, rec2)
예제 #5
0
 def test_for_rectangle_and_rectangle5(self):
     """the fifth test for checking if a given rectangle is located
     inside another given rectangle with them intersecting each
     other
     """
     
     v1 = shapes.Point(-2.5, 0)
     v2 = shapes.Point(0, -2.5)
     v3 = shapes.Point(2.5, 0)
     v4 = shapes.Point(0, 2.5)
     rec1 = shapes.Rectangle(v1, v2, v3, v4)
     v5 = shapes.Point(-2, -2)
     v6 = shapes.Point(2, -2)
     v7 = shapes.Point(2, 2)
     v8 = shapes.Point(-2, 2)
     rec2 = shapes.Rectangle(v5, v6, v7, v8)
     self.assertFalse(operations.is_inside(rec1, rec2))
예제 #6
0
 def test_for_rectangle_and_rectangle2(self):
     """the second test for checking if a given rectangle is located
     inside another given rectangle with the second one being
     located iside the first one
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec1 = shapes.Rectangle(v1, v2, v3, v4)
     v5 = shapes.Point(-1, 0)
     v6 = shapes.Point(0, -1)
     v7 = shapes.Point(1, 0)
     v8 = shapes.Point(0, 1)
     rec2 = shapes.Rectangle(v5, v6, v7, v8)
     self.assertFalse(operations.is_inside(rec1, rec2))
예제 #7
0
    def test_area(self):
        """testing the 'area' method of Rectangle class"""

        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 1)
        vertex4 = shapes.Point(0, 1)
        instance = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        self.assertEqual(instance.area, 1)
예제 #8
0
 def test_for_rectangle_and_rectangle4(self):
     """the fourth test for checking if a given rectangle is located
     inside another given rectangle with the first one being inside
     the second one but its vertices touching the second rectangle's
     perimeter
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec1 = shapes.Rectangle(v1, v2, v3, v4)
     v5 = shapes.Point(-2, -2)
     v6 = shapes.Point(2, -2)
     v7 = shapes.Point(2, 2)
     v8 = shapes.Point(-2, 2)
     rec2 = shapes.Rectangle(v5, v6, v7, v8)
     self.assertFalse(operations.is_inside(rec1, rec2))
예제 #9
0
    def test_center(self):
        """testing the 'centre' method of Rectangle class"""

        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 1)
        vertex4 = shapes.Point(0, 1)
        instance = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        expected = shapes.Point(0.5, 0.5)
        self.assertEqual(instance.center, expected)
예제 #10
0
    def test_circumcircle(self):
        """testing the 'circumcircle' method of Rectangle class"""

        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 2)
        vertex4 = shapes.Point(0, 2)
        instance = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        expected = shapes.Circle(shapes.Point(0.5, 1), np.sqrt(5))
        self.assertEqual(instance.circumcircle, expected)
예제 #11
0
 def test_for_rectangle_and_point(self):
     """test for checking if a given rectangle is located inside a
     given point which should always return False
     """
     
     v1 = shapes.Point(-1, -1)
     v2 = shapes.Point(1, -1)
     v3 = shapes.Point(1, 1)
     v4 = shapes.Point(-1, 1)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     point = shapes.Point(0, 0)
     self.assertFalse(operations.is_inside(rec, point))
예제 #12
0
 def test_for_rectangle_and_line(self):
     """testing if a given rectangle is located insied a given
     infinite line which should always return False
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     line = shapes.Line(1, 0)
     self.assertFalse(operations.is_inside(rec, line))
예제 #13
0
    def test_from_diagonal1(self):
        """testing the 'from_diagonal' method of Rectangle class"""

        end1 = shapes.Point(0, 0)
        end2 = shapes.Point(1, 1)
        instance1 = shapes.Rectangle.from_diagonal(diagonal=shapes.LineSegment(end1, end2))
        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 1)
        vertex4 = shapes.Point(0, 1)
        instance2 = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        self.assertEqual(instance1, instance2)
예제 #14
0
 def test_for_circle_and_rectangle4(self):
     """the fourth test for checking if a given circle is located
     inside a given rectangle with them being fully apart
     """
     
     circle = shapes.Circle(shapes.Point(10, 10), 1)
     v1 = shapes.Point(-2, -2)
     v2 = shapes.Point(2, -2)
     v3 = shapes.Point(2, 2)
     v4 = shapes.Point(-2, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(circle, rec))
예제 #15
0
    def test_diagonals(self):
        """testing the 'diagonals' method of Rectangle class"""

        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 1)
        vertex4 = shapes.Point(0, 1)
        instance = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        diagonal1 = shapes.LineSegment(end1=shapes.Point(0, 0), end2=shapes.Point(1, 1))
        diagonal2 = shapes.LineSegment(end1=shapes.Point(1, 0), end2=shapes.Point(0, 1))
        expected = (diagonal1, diagonal2)
        self.assertEqual(instance.diagonals, expected)
예제 #16
0
 def test_for_rectangle_and_circle5(self):
     """the fifth test for checking if a given rectangle is located
     inside a given circle with them being fully apart
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     circle = shapes.Circle(shapes.Point(5, 5), 1)
     self.assertFalse(operations.is_inside(rec, circle))
예제 #17
0
 def test_for_line_and_rectangle(self):
     """testing if a given infinite line is located inside a given
     rectangle which should always return False
     """
     
     line = shapes.Line(1, 0)
     v1 = shapes.Point(-1, -1)
     v2 = shapes.Point(1, -1)
     v3 = shapes.Point(1, 1)
     v4 = shapes.Point(-1, 1)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(line, rec))
예제 #18
0
 def test_for_circle_and_rectangle3(self):
     """the third test for checking if a given circle is located
     inside a given rectangle with the circle intersecting the 
     rectangle
     """
     
     circle = shapes.Circle(shapes.Point(0, -3), 2)
     v1 = shapes.Point(-2, -2)
     v2 = shapes.Point(2, -2)
     v3 = shapes.Point(2, 2)
     v4 = shapes.Point(-2, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(circle, rec))
예제 #19
0
 def test_for_circle_and_rectangle2(self):
     """the second test for checking if a given circle is located
     inside a given rectangle with the circle being inside the
     rectangle but touching one of its edges
     """
     
     circle = shapes.Circle(shapes.Point(0, -1), 2)
     v1 = shapes.Point(-2, -2)
     v2 = shapes.Point(2, -2)
     v3 = shapes.Point(2, 2)
     v4 = shapes.Point(-2, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(circle, rec))
예제 #20
0
 def test_for_circle_and_rectangle1(self):
     """the first test for checking if a given circle is located
     inside a given rectangle with the circle being fully inside
     the rectangle
     """
     
     circle = shapes.Circle(shapes.Point(0, 0), 1)
     v1 = shapes.Point(-2, -2)
     v2 = shapes.Point(2, -2)
     v3 = shapes.Point(2, 2)
     v4 = shapes.Point(-2, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertTrue(operations.is_inside(circle, rec))
예제 #21
0
 def test_for_rectangle_and_circle4(self):
     """the fourth test for checking if a given rectangle is located
     inside a given circle with the rectangle being partly inside the
     circle but intersecting with it
     """
     
     v1 = shapes.Point(0, 0)
     v2 = shapes.Point(2, -2)
     v3 = shapes.Point(4, 0)
     v4 = shapes.Point(2, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     circle = shapes.Circle(shapes.Point(0, 0), 1)
     self.assertFalse(operations.is_inside(rec, circle))
예제 #22
0
 def test_for_rectangle_and_circle2(self):
     """the second test for checking if a given rectangle is located
     inside a given circle with the circle being completely inside
     the rectangle
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     circle = shapes.Circle(shapes.Point(0, 0), 0.1)
     self.assertFalse(operations.is_inside(rec, circle))
예제 #23
0
 def test_for_rectangle_and_circle3(self):
     """the third test for checking if a given rectangle is located
     inside a given circle with the rectangle being inside the
     circle but with its vertices touching the circle's perimeter
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     circle = shapes.Circle(shapes.Point(0, 0), 2)
     self.assertFalse(operations.is_inside(rec, circle))
예제 #24
0
    def test_midlines(self):
        """testing the 'midlines' method of Rectangle class"""

        v1 = shapes.Point(0, 0)
        v2 = shapes.Point(1, 0)
        v3 = shapes.Point(1, 2)
        v4 = shapes.Point(0, 2)
        rec = shapes.Rectangle(v1, v2, v3, v4)
        midline1 = shapes.LineSegment(end1 = shapes.Point(0.5, 0), end2 = shapes.Point(0.5, 2))
        midline2 = shapes.LineSegment(end1 = shapes.Point(0, 1), end2 = shapes.Point(1, 1))
        expected = [midline1, midline2]
        res = rec.midlines
        self.assertEqual(set(res), set(expected))
예제 #25
0
 def test_for_rectangle_and_circle1(self):
     """the first test for checking if a rectangle is located inside
     a given circle with the rectangle being located inside the circle
     completely
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     circle = shapes.Circle(shapes.Point(0, 0), 5)
     self.assertTrue(operations.is_inside(rec, circle))
예제 #26
0
 def test_for_linesegment_and_rectangle4(self):
     """the fourth test for checking if a given line segment is
     located inside a given rectangle with them being fully apart
     """
     
     end1 = shapes.Point(10, 10)
     end2 = shapes.Point(11, 11)
     line = shapes.LineSegment(end1, end2)
     v1 = shapes.Point(-1, -1)
     v2 = shapes.Point(1, -1)
     v3 = shapes.Point(1, 1)
     v4 = shapes.Point(-1, 1)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(line, rec))
예제 #27
0
    def test_from_diagonal2(self):
        """testing the 'from_diagonal' method of Rectangle class with
        ends given to the diagonal in an order different from
        test_from_diagonal1 test method"""

        end2 = shapes.Point(0, 0)
        end1 = shapes.Point(1, 1)
        instance1 = shapes.Rectangle.from_diagonal(diagonal=shapes.LineSegment(end1, end2))
        vertex1 = shapes.Point(0, 0)
        vertex2 = shapes.Point(1, 0)
        vertex3 = shapes.Point(1, 1)
        vertex4 = shapes.Point(0, 1)
        instance2 = shapes.Rectangle(vertex1, vertex2, vertex3, vertex4)
        self.assertEqual(instance1, instance2)
예제 #28
0
 def test_for_rectangle_and_linesegment(self):
     """testing if a given rectangle is located inside a given
     line segment which should always return False
     """
     
     v1 = shapes.Point(-2, 0)
     v2 = shapes.Point(0, -2)
     v3 = shapes.Point(2, 0)
     v4 = shapes.Point(0, 2)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     end1 = shapes.Point(0, 0)
     end2 = shapes.Point(1, 1)
     line = shapes.LineSegment(end1, end2)
     self.assertFalse(operations.is_inside(rec, line))
예제 #29
0
 def test_for_linesegment_and_rectangle3(self):
     """the third test for checking if a given line segment is
     located inside a given rectangle with them intersecting each
     other
     """
     
     end1 = shapes.Point(0, 0)
     end2 = shapes.Point(2, 0.5)
     line = shapes.LineSegment(end1, end2)
     v1 = shapes.Point(-1, -1)
     v2 = shapes.Point(1, -1)
     v3 = shapes.Point(1, 1)
     v4 = shapes.Point(-1, 1)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertFalse(operations.is_inside(line, rec))
예제 #30
0
 def test_for_linesegment_and_rectangle1(self):
     """the first test for checking if a given line segment is
     located inside a given rectangle with the line segment being
     fully inside the rectangle
     """
     
     end1 = shapes.Point(0, 0)
     end2 = shapes.Point(0.5, 0.5)
     line = shapes.LineSegment(end1, end2)
     v1 = shapes.Point(-1, -1)
     v2 = shapes.Point(1, -1)
     v3 = shapes.Point(1, 1)
     v4 = shapes.Point(-1, 1)
     rec = shapes.Rectangle(v1, v2, v3, v4)
     self.assertTrue(operations.is_inside(line, rec))