def test_from_crossratio(self): a = Point(0, 1) b = Point(0, -1) c = Point(1.5, 0.5) d = Point(1.5, -0.5) e = Point(-1.5, 0.5) conic1 = Conic.from_points(a, b, c, d, e) cr = crossratio(a, b, c, d, e) conic2 = Conic.from_crossratio(cr, a, b, c, d) assert conic1 == conic2
def test_from_foci(self): f1 = Point(0, np.sqrt(5)) f2 = Point(0, -np.sqrt(5)) b = Point(0, 3) conic = Conic.from_foci(f1, f2, b) assert conic == Ellipse(Point(0, 0), 2, 3)
def test_components(self): l = Line(1, 2, 3) m = Line(4, 5, 6) g = Line(3, 2, 1) h = Line(6, 5, 4) q = QuadricCollection([Conic.from_lines(l, m), Conic.from_lines(g, h)]) assert q.components == [LineCollection([m, g]), LineCollection([l, h])] e = Plane(1, 2, 3, 4) f = Plane(4, 3, 2, 1) g = Plane(5, 6, 7, 8) h = Plane(8, 7, 6, 5) q = QuadricCollection([Quadric.from_planes(e, f), Quadric.from_planes(g, h)]) assert q.components == [PlaneCollection([e, g]), PlaneCollection([f, h])]
def test_from_tangent(self): a = Point(-1.5, 0.5) b = Point(0, -1) c = Point(1.5, 0.5) d = Point(1.5, -0.5) l = Line(0, 1, -1) conic = Conic.from_tangent(l, a, b, c, d) assert conic.contains(a) assert conic.contains(b) assert conic.contains(c) assert conic.contains(d) assert conic.is_tangent(l)
def test_from_points(self): a = Point(0, 1) b = Point(0, -1) c = Point(1.5, 0.5) d = Point(1.5, -0.5) e = Point(-1.5, 0.5) conic = Conic.from_points(a, b, c, d, e) assert conic.contains(a) assert conic.contains(b) assert conic.contains(c) assert conic.contains(d) assert conic.contains(e)
def test_from_points(self): a = Point(-1, 0) b = Point(0, 3) c = Point(1, 2) d = Point(2, 1) e = Point(0, -1) conic = Conic.from_points(a, b, c, d, e) assert conic.contains(a) assert conic.contains(b) assert conic.contains(c) assert conic.contains(d) assert conic.contains(e)
def test_intersect(self): c = Circle(Point(0, 0), 1) i = c.intersect(Line(0, 1, 0)) assert len(i) == 2 assert Point(1, 0) in i assert Point(-1, 0) in i c2 = Circle(Point(0, 2), 1) assert Point(0, 1) in c.intersect(c2) c3 = Conic.from_lines(Line(1, 0, 0), Line(0, 1, 0)) assert Point(1, 0) in c.intersect(c3) assert Point(0, 1) in c.intersect(c3) assert Point(-1, 0) in c.intersect(c3) assert Point(0, -1) in c.intersect(c3)
def test_contains(self): c = Conic([[1, 0, 0], [0, 1, 0], [0, 0, -1]]) assert c.contains(Point(1, 0))