示例#1
0
bck = vp.load(datadir + "images/schrod.png").alpha(.3).scale(.0255).pos(
    [0, -5, -.1])
barrier = Line(np.stack((x, V * 15, np.zeros_like(x)), axis=1),
               c="black",
               lw=2)

lines = []
for i in range(0, Nsteps):
    for j in range(500):
        Psi += d_dt(Psi) * dt  # integrate for a while before showing things
    A = np.real(Psi * np.conj(Psi)) * 1.5  # psi squared, probability(x)
    coords = np.stack((x, A, np.zeros_like(x)), axis=1)
    Aline = Line(coords, c="db", lw=3)
    vp.show([Aline, barrier, bck])
    lines.append([Aline, A])  # store objects

# now show the same lines along z representing time
vp.actors = []  # clean up internal list of objects to show
vp.camera.Elevation(20)
vp.camera.Azimuth(20)
bck.alpha(1)
for i in range(Nsteps):
    p = [0, 0, i * size / Nsteps]  # shift along z
    l, a = lines[i]
    l.cmap("gist_earth_r", a)
    vp += [l.pos(p), barrier.clone().alpha(0.3).pos(p)]
    vp.show()

vp.show(interactive=1)
示例#2
0

plt = Plotter(interactive=False)
bck = plt.load(dataurl+"images/schrod.png").alpha(.3).scale(.0256).pos([0,-5,-.1])
barrier = Line(np.stack((x, V*15, np.zeros_like(x)), axis=1), c="black", lw=2)
box = bck.box().c('black')

lines = []
for i in range(0, Nsteps):
    for j in range(500):
        Psi += d_dt(Psi) * dt  # integrate for a while before showing things
    A = np.real(Psi * np.conj(Psi)) * 1.5  # psi squared, probability(x)
    coords = np.stack((x, A), axis=1)
    Aline = Line(coords, c="db", lw=3)
    plt.show(barrier, bck, Aline, box).remove(Aline)
    lines.append([Aline, A])   # store objects

# now show the same lines along z representing time
plt.actors= [] # clean up internal list of objects to show
plt.camera.Elevation(20)
plt.camera.Azimuth(20)
bck.alpha(1)
for i in range(Nsteps):
    p = [0, 0, i*size/Nsteps]  # shift along z
    l, a = lines[i]
    l.cmap("gist_earth_r", a)
    plt += [box, bck, l.pos(p), barrier.clone().alpha(0.3).pos(p)]
    plt.show()

interactive().close()
示例#3
0
"""Forward kinematics: hover the mouse to drag the chain"""
from vedo import Plotter, versor, Plane, Line

n = 15  # number of points
l = 3  # length of one segment


def move(evt):
    if not evt.actor:
        return
    coords = line.points()
    coords[0] = evt.picked3d
    for i in range(1, n):
        v = versor(coords[i] - coords[i - 1])
        coords[i] = coords[i - 1] + v * l
    line.points(coords)  # update positions
    nodes.points(coords)
    plt.render()


plt = Plotter()
plt.addCallback("mouse move", move)

surf = Plane(sx=60, sy=60)
line = Line([l * n / 2, 0], [-l * n / 2, 0], res=n, lw=12)
nodes = line.clone().c('red3').pointSize(15)

plt.show(surf, line, nodes, __doc__, zoom=1.3).close()