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)
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)
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)