Exemplo n.º 1
0
    def test_intersection(self):
        c = Circle(Point(0, 2), 2)
        l = Line(Point(-1, 2), Point(1, 2))

        assert c.contains(Point(0, 0))
        assert c.intersect(l) == [Point(-2, 2), Point(2, 2)]
        assert c.intersect(l-Point(0, 2)) == [Point(0, 0)]
Exemplo n.º 2
0
    def test_intersect(self):
        c = Circle(Point(0, 2), 2)
        l = Line(Point(-1, 2), Point(1, 2))

        assert c.contains(Point(0, 0))
        assert c.intersect(l) == [Point(-2, 2), Point(2, 2)]
        assert c.intersect(l - Point(0, 2)) == [Point(0, 0)]

        l = LineCollection(
            [Line(Point(-1, 2), Point(1, 2)),
             Line(Point(0, 2), Point(0, 0))])
        assert c.intersect(l) == [
            PointCollection([Point(-2, 2), Point(0, 0)]),
            PointCollection([Point(2, 2), Point(0, 4)]),
        ]

        c1 = Circle(Point(0, 0), 5)
        c2 = Circle(Point(8, 0), 5)
        intersections = c1.intersect(c2)
        assert Point(4, 3) in intersections
        assert Point(4, -3) in intersections
Exemplo n.º 3
0
    def test_intersect(self):
        c = Circle(Point(0, 2), 2)
        l = Line(Point(-1, 2), Point(1, 2))

        assert c.contains(Point(0, 0))
        assert c.intersect(l) == [Point(-2, 2), Point(2, 2)]
        assert c.intersect(l - Point(0, 2)) == [Point(0, 0)]

        l = LineCollection([Line(Point(-1, 2), Point(1, 2)), Line(Point(0, 2), Point(0, 0))])
        assert c.intersect(l) == [PointCollection([Point(-2, 2), Point(0, 0)]),
                                  PointCollection([Point(2, 2), Point(0, 4)])]

        c1 = Circle(Point(0, 0), 5)
        c2 = Circle(Point(8, 0), 5)
        intersections = c1.intersect(c2)
        assert Point(4, 3) in intersections
        assert Point(4, -3) in intersections

        c1 = Circle(Point(0, 0))
        c2 = Circle(Point(0.5, 0))
        i = c1.intersect(c2)
        assert len(i) == 4
        assert len([p for p in i if p.isreal]) == 2
Exemplo n.º 4
0
 def test_contains(self):
     c = Circle(Point(0, 1), 1)
     assert c.contains(Point(0, 2))
     assert c.contains(Point(1, 1))
Exemplo n.º 5
0
 def test_circle(self):
     c = Circle(Point(0, 1), 1)
     assert c.contains(Point(0, 2))
     assert c.contains(Point(1, 1))
     assert c.tangent(at=Point(0, 0)) == Line(0, 1, 0)
     assert c.center == Point(0, 1)