Exemplo n.º 1
0
    def test_meet(self):
        # three planes
        a = PlaneCollection([Plane(1, 0, 0, 0), Plane(1, 0, 0, -1)])
        b = PlaneCollection([Plane(0, 1, 0, 0), Plane(0, 1, 0, -1)])
        c = PlaneCollection([Plane(0, 0, 1, 0), Plane(0, 0, 1, -1)])
        assert meet(a, b, c) == PointCollection([Point(0, 0, 0), Point(1, 1, 1)])

        # two planes
        l = a.meet(b)
        m = LineCollection(
            [Line(Point(0, 0, 0), Point(0, 0, 1)), Line(Point(1, 1, 0), Point(1, 1, 1))]
        )
        assert l == m

        # two lines in 2D
        a = LineCollection([Line(0, 1, 0), Line(0, 1, -1)])
        b = LineCollection([Line(1, 0, 0), Line(1, 0, -1)])
        assert a.meet(b) == PointCollection([Point(0, 0), Point(1, 1)])

        # two lines in 3D
        a = LineCollection(
            [Line(Point(0, 0, 0), Point(0, 0, 1)), Line(Point(1, 0, 0), Point(1, 0, 1))]
        )
        b = LineCollection(
            [Line(Point(0, 0, 0), Point(0, 1, 0)), Line(Point(1, 0, 0), Point(1, 1, 0))]
        )
        assert a.meet(b) == PointCollection([Point(0, 0, 0), Point(1, 0, 0)])

        # plane and line
        a = LineCollection(
            [Line(Point(0, 0, 0), Point(0, 0, 1)), Line(Point(1, 0, 0), Point(1, 0, 1))]
        )
        b = PlaneCollection([Plane(0, 0, 1, 0), Plane(0, 0, 1, -1)])
        assert a.meet(b) == PointCollection([Point(0, 0, 0), Point(1, 0, 1)])
Exemplo n.º 2
0
    def test_meet(self):
        p1 = Plane(1, 0, 0, 0, 0)
        p2 = Plane(0, 1, 0, 0, 0)
        p3 = Plane(0, 0, 1, 0, 0)
        p4 = Plane(0, 0, 0, 1, 0)

        # four hyperplanes
        assert meet(p1, p2, p3, p4) == Point(0, 0, 0, 0)

        # hyperplane and line
        l = Line(Point(0, 0, 0, 0), Point(0, 0, 1, 0))
        assert p3.meet(l) == Point(0, 0, 0, 0)

        # two lines
        m = Line(Point(0, 0, 0, 0), Point(1, 2, 5, 6))
        assert l.meet(m) == Point(0, 0, 0, 0)
Exemplo n.º 3
0
    def test_meet(self):
        p1 = Plane(1, 0, 0, 0)
        p2 = Plane(0, 0, 1, 0)
        p3 = Plane(0, 1, 0, 0)

        # three planes
        assert meet(p1, p2, p3) == Point(0, 0, 0)

        # two planes
        l = p1.meet(p2)
        m = Line(Point(0, 0, 0), Point(0, 1, 0))
        assert l == m

        # two lines
        m = Line(Point(0, 0, 0), Point(1, 2, 5))
        assert l.meet(m) == Point(0, 0, 0)

        # plane and line
        assert p3.meet(l) == Point(0, 0, 0)