Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
def Line(i, n=5): return line([(cos(pi*i/n),sin(pi*i/n)), (-cos(pi*i/(n+1)),-sin(pi*i/(n+1)))]) def Cuts(n): return sum(Line(i, n) for i in range(n)) def Demo(n, m=0): for i in range(1, n): x = -1+2*i/(n+1) yield line([(x, 1), (x, -1)]) x = -1+2*n/(n+1) yield line([(x, 1), (x-2*m/n, -1)]) Dessin1 = [circle((0, 0), 1) + Cuts(i) for i in range(6)] Dessin2 = [circle((0, 0), 1) + sum(Demo(5, i)) for i in range(5)] Dessin3 = [circle((0, 0), 1) + sum(Demo(i)) for i in range(1, 6)] Dessin1 + Dessin2 + Dessin3
[, , , , , , , , , , , , , , , ]
colors = ['red', 'green', 'blue', 'yellow', 'purple'] def b(i, n): return i / (n + 1) if i > -1 else 1 def d(i, n): return (n - 1)**(i - 2) / (n + 1) if i else 0 def Function(i, n): return lambda x, y: (1 - d(i, n) - b(i, n)) * x - (1 - d(i-1, n) - b(i-1, n)) * y + b(i, n) def Plane(i, n): f = Function(i, n) return plot3d(f, (-1.5, 1.5), (-1.5, 1.5), color=colors[i%len(colors)], opacity=0.6) def Planes(n): return sum(Plane(i, n) for i in range(n)) Cube = cube((0, 0, 0), 2, opacity=0.3) Cube + Planes(4)
Cube + Planes(5)