Exemplo n.º 1
0
coords2 = a2.coordinates()
pts2 = vp.points(coords2, r=1, legend='#points = ' + str(len(coords2)))
vp.show([a2, pts2], at=1, interactive=True)

########################################################################################
# Draw a bunch of simple objects on separate parts of the rendering window:
# split window to best accomodate 9 renderers
vp = Plotter(N=9, title='basic shapes')
vp.sharecam = False  # each object can be moved independently
vp.show(at=0, actors=vp.arrow([0, 0, 0], [1, 1, 1]), legend='arrow')
vp.show(at=1, actors=vp.line([0, 0, 0], [1, 1, 1]), legend='line')
vp.show(at=2, actors=vp.points([[0, 0, 0], [1, 1, 1]]), legend='points')
vp.show(at=3, actors=vp.text('Hello!'))
vp.show(at=4, actors=vp.sphere())
vp.show(at=5, actors=vp.cube(), legend='cube')
vp.show(at=6, actors=vp.ring(), legend='ring')
vp.show(at=7, actors=vp.helix(), legend='helix')
vp.show(at=8, actors=vp.cylinder(), legend='cylinder', interactive=1)

########################################################################################
# Draw a bunch of objects from various mesh formats. Loading is automatic.
vp = Plotter(shape=(3, 3),
             title='mesh formats')  # split window in 3 rows and 3 columns
vp.sharecam = False  # each object can be moved independently
vp.show('data/beethoven.ply', at=0, c=0, axes=0,
        ruler=1)  # dont show axes, add a ruler
vp.show('data/cow.g', at=1, c=1, zoom=1.15)  # make it 15% bigger
vp.show('data/limb.pcd', at=2, c=2)
vp.show('data/ring.gmsh', at=3, c=3, wire=1)
vp.show('data/images/dog.jpg', at=4)  # 2d images can be loaded the same way
vp.show('data/shuttle.obj', at=5, c=5)
Exemplo n.º 2
0
Ratom = 0.025  # wildly exaggerated size of helium atom
RingThickness = 0.3  # thickness of the toroid
RingRadius = 1
k = 1.4E-23  # Boltzmann constant
T = 300  # room temperature
dt = 1E-5
#############################################################


def reflection(p, pos):
    n = norm(pos)
    return np.dot(np.identity(3) - 2 * n * n[:, np.newaxis], p)


vp = Plotter(title='gas in toroid', verbose=0, axes=0)
vp.ring(c='g', r=RingRadius, thickness=RingThickness, alpha=.1,
        wire=1)  ### <--

Atoms = []
poslist = []
plist, mlist, rlist = [], [], []
mass = Matom * Ratom**3 / Ratom**3
pavg = np.sqrt(2. * mass * 1.5 * k *
               T)  # average kinetic energy p**2/(2mass) = (3/2)kT

for i in range(Natoms):
    alpha = 2 * np.pi * random()
    x = RingRadius * np.cos(alpha) * .9
    y = RingRadius * np.sin(alpha) * .9
    z = 0
    Atoms = Atoms + [vp.sphere(pos=(x, y, z), r=Ratom, c=i)]  ### <--
    theta = np.pi * random()
Exemplo n.º 3
0
        R12 = Pos[s2] - Pos[s1]
        nR12 = np.linalg.norm(R12)
        d12 = Radius[s1] + Radius[s2] - nR12
        tau = R12 / nR12
        DR0 = d12 * tau
        x1 = Mass[s1] / (Mass[s1] + Mass[s2])
        x2 = 1 - x1  # x2 = Mass[s2]/(Mass[s1]+Mass[s2])
        Pos[s1] -= x2 * DR0
        Pos[s2] += x1 * DR0
        DV0 = 2 * dot(Vel[s2] - Vel[s1], tau) * tau
        Vel[s1] += x2 * DV0
        Vel[s2] -= x1 * DV0

    # Update the location of the spheres
    for s in range(Nsp):
        Spheres[s].pos([Pos[s][0], Pos[s][1], 0])

    if not int(i) % 10:  # every ten steps:
        rsp = [Pos[0][0], Pos[0][1], 0]
        rsv = [Vel[0][0], Vel[0][1], 0]
        p = vp.ring(pos=rsp,
                    axis=rsv,
                    r=Rb / 4,
                    thickness=Rb / 40,
                    c='r',
                    alpha=0.05)  # leave an oriented trace
        vp.render(p)  # add actor p and render scene
    pb.print('#actors=' + str(len(vp.actors)))

vp.show(interactive=1)