def animation3(targdir="anim3"): targdir = 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(targdir,filename), "w") as target: target.write(pov_header) cubocta = Cuboctahedron() cubocta.vert_radius = radius cubocta.vert_color = "rgb <1,0,0>" if frame_id <= 9: 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: cube = Cube() ico = Icosahedron() * (1/PHI * math.sqrt(2)/2) * 1.2 * radius st = Struts(cube, ico) draw_poly(ico, target) draw_poly(st, target) # draw_poly(cube, target) for ik in twelve_around_one(ico): draw_poly(ik, target) # for c in twelve_around_one(cube): # draw_poly(c, target) for s in twelve_around_one(st): draw_poly(s, target)
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 cubocta_in_cube_lattice(): with open("cubocta.pov", "w") as target: target.write(pov_header) cubocta = Cuboctahedron() cube = Cube() draw_poly(cubocta, target) for c in twelve_around_one(cube): draw_poly(c, 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)