Ejemplo n.º 1
0
def init_gr3():
    def log_callback(message):
        print "Log: ", message
    gr3.setlogcallback(log_callback)
    
    gr3.init([gr3.GR3_InitAttribute.GR3_IA_FRAMEBUFFER_WIDTH, 1024, gr3.GR3_InitAttribute.GR3_IA_FRAMEBUFFER_HEIGHT, 1024])
    print gr3.getrenderpathstring()
    
    # Atome zeichnen
    gr3.drawspheremesh(len(atom_data), sphere_positions, sphere_colors, sphere_radii)
    # Atombindungen zeichnen
    gr3.drawcylindermesh(len(cylinder_positions), cylinder_positions, cylinder_directions, cylinder_colors, cylinder_radii, cylinder_lengths)
Ejemplo n.º 2
0
def init_gr3():
    def log_callback(message):
        print("Log: ", message)

    gr3.setlogcallback(log_callback)

    gr3.init([
        gr3.GR3_InitAttribute.GR3_IA_FRAMEBUFFER_WIDTH, 1024,
        gr3.GR3_InitAttribute.GR3_IA_FRAMEBUFFER_HEIGHT, 1024
    ])
    print(gr3.getrenderpathstring())

    # draw atoms
    gr3.drawspheremesh(len(atom_data), sphere_positions, sphere_colors,
                       sphere_radii)
    # draw atomic bonds
    gr3.drawcylindermesh(len(cylinder_positions), cylinder_positions,
                         cylinder_directions, cylinder_colors, cylinder_radii,
                         cylinder_lengths)
Ejemplo n.º 3
0
    gr.textext(0.05, 0.12, '\\omega:%7.2f' % omega)
    gr.settextcolorind(2)
    gr.textext(0.05, 0.08, 'y_{A}:%6.2f' % acceleration)
    gr.updatews()
    return


theta = 110.0  # initial angle
gamma = 0.1  # damping coefficient
L = 1  # pendulum length

t = 0
dt = 0.04
state = array([theta * pi / 180, 0])

gr3.init()
gr3.setcameraprojectionparameters(45, 1, 100)
gr3.cameralookat(0, -2, 6, 0, -2, 0, 0, 1, 0)
gr3.setbackgroundcolor(1, 1, 1, 1)
gr3.setlightdirection(1, 1, 10)

now = time.clock()

while t < 30:
    start = now

    t, state = rk4(t, dt, state, damped_pendulum_deriv)
    theta, omega = state
    acceleration = sqrt(2 * g * L * (1 - cos(theta)))
    pendulum(t, theta, omega, acceleration)
Ejemplo n.º 4
0
def draw(mesh, x=None, y=None, z=None):
    gr3.clear()
    gr3.drawmesh(mesh, 1, (0,0,0), (0,0,1), (0,1,0), (1,1,1), (1,1,1))
    gr3.drawslicemeshes(data,  x=x, y=y, z=z)
    gr.clearws()
    gr3.drawimage(0, 1, 0, 1, 500, 500, gr3.GR3_Drawable.GR3_DRAWABLE_GKS)
    gr.updatews()

data = np.fromfile("mri.raw", np.uint16)
data = data.reshape((64, 64, 93))
data[data > 2000] = 2000
data[:, :, :] = data / 2000.0 * np.iinfo(np.uint16).max

gr.setviewport(0, 1, 0, 1)
gr3.init()
gr3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
mesh = gr3.createisosurfacemesh(data, isolevel=40000)

gr.setcolormap(1)
for z in np.linspace(0, 1, 300):
    draw(mesh, x=0.9, z=z)
for y in np.linspace(1, 0.5, 300):
    draw(mesh, x=0.9, y=y, z=1)
gr.setcolormap(19)
for x in np.linspace(0.9, 0, 300):
    draw(mesh, x=x, y=0.5, z=1)
for x in np.linspace(0, 0.9, 300):
    draw(mesh, x=x, z=1)

gr3.terminate()