コード例 #1
0
    def test_contains(self):
        a = Point(0, 0)
        b = Point(0, 2)
        c = Point(2, 2)
        d = Point(2, 0)
        r = Rectangle(a, b, c, d)

        assert r.contains(a)
        assert r.contains(b)
        assert r.contains(c)
        assert r.contains(d)
        assert r.contains(Point(1, 1))
        assert not r.contains(Point([1, 1, 0]))

        a = Point(0, 0, 1)
        b = Point(1, 3, 1)
        c = Point(2, 0, 1)
        d = Point(1, 1, 1)
        p = Polygon(a, b, c, d)

        assert p.contains(Point(0.5, 1, 1))
        assert not p.contains(Point(0.5, 1, 0))
        assert np.all(
            p.contains(PointCollection([Point(0.5, 1, 1),
                                        Point(1.5, 1, 1)])))
        assert np.all(p.contains(PointCollection([a, c, d])))

        t = Triangle(Point(0, 0), Point(0, 2), Point(2, 1))

        assert t.contains(Point(1, 1))
        assert not t.contains(Point(-1, 1))
        assert not t.contains(Point([1, 1, 0]))
コード例 #2
0
ファイル: test_shapes.py プロジェクト: jan-mue/geometer
    def test_circumcenter(self):
        a = Point(0, 0, 1)
        b = Point(2, 0, 1)
        c = Point(2, 2, 1)
        t = Triangle(a, b, c)

        assert t.circumcenter == Point(1, 1, 1)
コード例 #3
0
ファイル: test_shapes.py プロジェクト: jan-mue/geometer
    def test_centroid(self):
        a = Point(0, 0, 1)
        b = Point(2, 0, 1)
        c = Point(2, 2, 1)
        t = Triangle(a, b, c)

        s1, s2, s3 = t.edges
        l1 = s1.midpoint.join(c)
        l2 = s2.midpoint.join(a)

        assert t.centroid == (a + b + c) / 3
        assert t.centroid == l1.meet(l2)
コード例 #4
0
ファイル: test_shapes.py プロジェクト: jan-mue/geometer
    def test_contains(self):
        a = Point(0, 0)
        b = Point(0, 2)
        c = Point(2, 1)
        t = Triangle(a, b, c)

        assert t.contains(Point(1, 1))
        assert all(t.contains(PointCollection([a, b, c])))
        assert not t.contains(Point(-1, 1))
        assert not t.contains(Point([1, 1, 0]))
コード例 #5
0
 def test_area(self):
     a = Point(0, 0)
     b = Point(2, 0)
     c = Point(0, 2)
     t = Triangle(a, b, c)
     assert np.isclose(t.area, 2)