def create_data(): global offset DB.connect() make_tables() save_coords() offset = 0 o = Tetrahedron() poly_faces(o, "TETRA") o = InvTetrahedron() poly_faces(o, "INVTET") o = Cube() poly_faces(o, "CUBE") o = Octahedron() poly_faces(o, "OCTA") o = RD() poly_faces(o, "RD") o = Cuboctahedron() poly_faces(o, "VE") #save_faces() save_polys() DB.disconnect()
def animation11(targdir="anim11"): targdir = os.path.join(".",targdir) if not os.path.isdir(targdir): os.mkdir(targdir) thirteen_balls = [Qvector((0,0,0,0))] + list(IVM_DIRS) neighbors = one_hop_away(thirteen_balls) colors = cycle(["rgb <1,0,0>", "rgb <.8,0,.2>", "rgb <.6,0,.4>", "rgb <.4,0,.6>", "rgb <.2,0,.8>", "rgb <0,.5,.2>", "rgb <0,.7,.2>"]) rainbow = [next(colors) for _ in range(13)] for frame_id in range(13): filename = f"balls{frame_id:03}.pov" with open(os.path.join(targdir,filename), "w") as target: target.write(pov_header) rd = RD() draw_poly(rd, target) for idx, p in enumerate(twelve_around_one(rd)): if idx <= frame_id: draw_vert(neighbors[idx], rainbow[idx], r=0.4, t=target) draw_poly(p, target) if 12 == frame_id: draw_vert(neighbors[12], rainbow[12], r=0.4, t=target)
def animation10(targdir="anim10"): targdir = os.path.join(".",targdir) if not os.path.isdir(targdir): os.mkdir(targdir) thirteen_balls = [Qvector((0,0,0,0))] + list(IVM_DIRS) neighbors = one_hop_away(thirteen_balls) for frame_id in range(13): filename = f"balls{frame_id:03}.pov" with open(os.path.join(targdir,filename), "w") as target: target.write(pov_header) rd = RD() draw_poly(rd, target) for idx, p in enumerate(twelve_around_one(rd)): if idx <= frame_id: draw_vert(neighbors[idx], c="rgb <1,0,0>", r=0.5, t=target) draw_poly(p, target) if 12 == frame_id: draw_vert(neighbors[12], c="rgb <1,0,0>", r=0.5, t=target)
def animation2(targdir="anim2"): path = os.path.join(".",targdir) if not os.path.isdir(targdir): os.mkdir(targdir) radii = np.linspace(0, 0.5, 8).tolist() radii += reversed(radii[1:-1]) for frame_id, radius in enumerate(radii, start=1): filename = f"balls{frame_id:03}.pov" with open(os.path.join(path,filename), "w") as target: target.write(pov_header) cubocta = Cuboctahedron() cubocta.vert_radius = radius cubocta.vert_color = "rgb <1,0,0>" draw_poly(cubocta, target, v=True, e=False) draw_vert(Qvector((0,0,0,0)), c=cubocta.vert_color, r=cubocta.vert_radius, t=target) if frame_id < 9: rd = RD() draw_poly(rd, target) for p in twelve_around_one(rd): draw_poly(p, target) draw_poly(Cuboctahedron(), target, v=True, e=True)
def ch(): with open("concentric_hierarchy.pov", "w") as target: target.write(pov_header) ico = Icosahedron() * 2 cubo = Cuboctahedron() * 2 cub = Cube() * 2 rd = RD() * 2 tet = Tetrahedron() * 2 octa = Octahedron() * 2 draw_poly(ico, target) draw_poly(cubo, target) draw_poly(rd, target) draw_poly(cub, target) draw_poly(tet, target) draw_poly(octa, target)
def spheres_bulging(): with open("sphere_pack2.pov", "w") as target: target.write(pov_header) cube = Cube() rd = RD() octa = Octahedron() cubocta = Cuboctahedron() draw_poly(cube, target) draw_poly(octa, target) draw_poly(rd, target) for p in twelve_around_one(cube): draw_poly(p, target) for p in twelve_around_one(rd): draw_poly(p, target) for p in twelve_around_one(octa): draw_poly(p, target) cubocta.vert_radius = Qvector((2,1,1,0)).length()/2 # grow the balls cubocta.vert_color = "rgb <1,0,0>" draw_poly(cubocta, target, v=True, e=False) draw_vert(Qvector((0,0,0,0)), c=cubocta.vert_color, r=cubocta.vert_radius, t=target)