Esempio n. 1
0
hanoi = Hanoi(nr_disks)

tower_states = list([hanoi.towers])
for _ in hanoi.moves():
    tower_states.append(hanoi.towers)

disks = {
    hanoi.nr_disks - i: Cylinder(r=0.2 * (hanoi.nr_disks - i + 1), c=i)
    for i in range(hanoi.nr_disks)
}

plt = Plotter(interactive=False, size=(800, 600), bg='wheat', bg2='lb')
plt += disks.values()
plt += Box(pos=(3, 0, -0.5), size=(12, 4, 0.1))
cam = dict(
    pos=(14.60, -20.56, 7.680),
    focalPoint=(3.067, 0.5583, 1.910),
    viewup=(-0.1043, 0.2088, 0.9724),
)
plt.show(camera=cam)

pb = ProgressBar(0, len(tower_states), 1, c="y")
for t in pb.range():
    pb.print()
    state = tower_states[t]
    for tower_nr in range(3):
        for i, disk in enumerate(state[tower_nr]):
            disks[disk].pos([3 * tower_nr, 0, i + 0.5])
    plt.render()
plt.interactive().close()
Esempio n. 2
0

vp = Plotter(shape=[2, 2], axes=3, interactive=0)

shape1 = Sphere(alpha=0.2)
shape2 = vp.load(datadir + "icosahedron.vtk").normalize().lineWidth(1)

agrid1, actorpts1 = makeGrid(shape1, N)

vp.show(shape1, actorpts1, at=0)

agrid2, actorpts2 = makeGrid(shape2, N)
vp.show(shape2, actorpts2, at=1)

vp.camera.Zoom(1.2)
vp.interactive = False

clm1 = pyshtools.SHGrid.from_array(agrid1).expand()
clm2 = pyshtools.SHGrid.from_array(agrid2).expand()
# clm1.plot_spectrum2d()  # plot the value of the sph harm. coefficients
# clm2.plot_spectrum2d()

for t in np.arange(0, 1, 0.005):
    act21 = Points(morph(clm2, clm1, t, lmax), c="r", r=4)
    act12 = Points(morph(clm1, clm2, t, lmax), c="g", r=4)

    vp.show(act21, at=2, resetcam=0)
    vp.show(act12, at=3)
    vp.camera.Azimuth(2)

vp.show(interactive=1)