Пример #1
0
    def test_perpendicular(self):
        p1 = PointCollection([(1, 1, 0), (1, 1, 5)], homogenize=True)
        p2 = PointCollection([(2, 1, 0), (2, 1, 5)], homogenize=True)
        p3 = PointCollection([(0, 0, 0), (0, 0, 5)], homogenize=True)
        l = LineCollection(p1, p2)
        m = l.perpendicular(p1)

        assert l.meet(m) == p1
        assert all(is_perpendicular(l, m))

        m = l.perpendicular(
            p3 + PointCollection([(1, 1, 0), (0, 0, 0)], homogenize=True)
        )

        assert all(is_perpendicular(l, m))

        e = PlaneCollection(l, p3)
        m = e.perpendicular(p1)

        assert e.meet(m) == p1
        assert all(is_perpendicular(l, m))

        m = e.perpendicular(p1 + PointCollection([m.direction[0], Point(0, 0, 0)]))

        assert e.meet(m) == p1
        assert all(is_perpendicular(l, m))
Пример #2
0
    def test_perpendicular(self):
        p = Point(1, 1, 0)
        q = Point(0, 0, 1)
        r = Point(1, 2, 3)
        l = Line(p, q)
        m = l.perpendicular(p)

        assert l.meet(m) == p
        assert is_perpendicular(l, m)

        m = l.perpendicular(r)

        assert is_perpendicular(l, m)

        e = Plane(l, r)
        m = e.perpendicular(p)

        assert e.meet(m) == p
        assert is_perpendicular(l, m)

        m = e.perpendicular(p + m.direction)

        assert e.meet(m) == p
        assert is_perpendicular(l, m)

        f = e.perpendicular(l)

        assert e.meet(f) == l
        assert is_perpendicular(e, f)
Пример #3
0
def test_angle_bisectors():
    a = Point(0, 0)
    b = Point(1, 1)
    c = Point(1, 0)
    l = Line(a, b)
    m = Line(a, c)
    q, r = angle_bisectors(l, m)
    assert is_perpendicular(q, r)
    assert np.isclose(angle(l, q), angle(q, m))

    p1 = Point(0, 0, 0)
    p2 = Point(0, 1, 0)
    p3 = Point(1, 0, 0)
    l = Line(p1, p2)
    m = Line(p1, p3)
    q, r = angle_bisectors(l, m)
    assert is_perpendicular(q, r)
    assert np.isclose(angle(l, q), angle(q, m))

    p1 = PointCollection([(0, 0), (0, 0)], homogenize=True)
    p2 = PointCollection([(1, 1), (0, 1)], homogenize=True)
    p3 = PointCollection([(1, 0), (1, 1)], homogenize=True)
    l = LineCollection(p1, p2)
    m = LineCollection(p1, p3)
    q, r = angle_bisectors(l, m)
    assert all(is_perpendicular(q, r))
    assert np.allclose(angle(l, q), angle(q, m))
Пример #4
0
    def test_perpendicular(self):
        p = Point(1, 1, 0)
        q = Point(0, 0, 1)
        l = Line(p, q)
        m = l.perpendicular(p)

        assert is_perpendicular(l, m)

        r = Point(1, 2, 3)
        e = Plane(p, q, r)
        m = e.perpendicular(p)

        assert is_perpendicular(l, m)
Пример #5
0
def test_is_perpendicular():
    l = Line(0, 1, 0)
    m = Line(1, 0, 0)
    assert is_perpendicular(l, m)

    p1 = Point(0, 0, 0)
    p2 = Point(0, 1, 0)
    p3 = Point(1, 0, 0)
    l = Line(p1, p2)
    m = Line(p1, p3)
    assert is_perpendicular(l, m)

    e1 = Plane(p1, p2, p3)
    e2 = Plane(p1, p2, Point(0, 0, 1))
    assert is_perpendicular(e1, e2)

    l = LineCollection([(0, 1, 0), (0, 1, 0)])
    m = LineCollection([(1, 0, 0), (1, -1, 0)])
    assert list(is_perpendicular(l, m)) == [True, False]

    e1 = PlaneCollection([(0, 0, 1, 0), (1, 0, 0, 0)])
    e2 = PlaneCollection([(0, 1, 0, 0), (0, 0, 1, 0)])
    assert all(is_perpendicular(e1, e2))
Пример #6
0
    def test_perpendicular(self):
        p = Point(1, 1)
        l = Line(1, 1, 0)
        m = l.perpendicular(p)

        assert m == Line(-1, 1, 0)

        m = l.perpendicular(Point(0, 0))
        assert m == Line(-1, 1, 0)

        p = Point(1, 1, 0)
        q = Point(0, 0, 1)
        l = Line(p, q)
        m = l.perpendicular(p)

        assert is_perpendicular(l, m)