# #Copyright (C) 2012 Mahomed Naim Abdul Kadir Gani #Escola Secundária da Ramada # #This program is free software; you can redistribute it and/or modify it under #the terms of the GNU General Public License as published by the Free Software #Foundation; either version 2 of the License, or (at your option) any later #version. # #This program is distributed in the hope that it will be useful, but WITHOUT #ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # from visual import* raio=0 m=0 densidade=0 while raio<=0: raio=float(input('Insira o valor do raio da bola ')) if raio<=0: print('Insira valores positivos') else: while m<=0: m=float(input('Insira o valor da massa da bola ')) if m<=0: print('Insira valores positivos') else: while densidade<=0: densidade=float(input('Insira o valor da densidade do liquido ')) if densidade <=0: print ('Insira valores positivos') else: break scene.height=600 scene.width=600 scene.center=(0,7,0) scene.range=(raio*75,15,5) #eixos eixo_x = arrow(pos=(-raio*25,0,0), axis=(raio*50,0,0), shaftwidth=0.01) eixo_y = arrow(pos=(-raio*25,0,0), axis=(0,10,0), shaftwidth=0.01) eixo_z = arrow(pos=(-raio*25,0,0), axis=(0,0,10), shaftwidth=0.01) #objetos bola = sphere (radius=raio, pos=(-raio*25,15,0),color=color.blue) liquido = cylinder(pos=(0,0,0), axis=(0,10,0), radius=raio*25, color=color.blue, opacity=0.4) chao = box(pos=(0,-0.5,0), size=(raio*50,1,raio*50), color=color.green) #constantes bola.volume = 4/3*pi*raio**3 deltat = 0.01 g=-9.8 #forças impulsao=abs(densidade*g*bola.volume) peso=m*g #extras caixa=label(pos=(-liquido.radius,0,0)) caixa2=label(pos=(liquido.radius,0,0)) #movimento bola.velocity = vector(2,0,0) a=vector(0,peso/m,0) while 1: rate(100) bola.velocity = bola.velocity + a*deltat bola.pos = bola.pos + bola.velocity*deltat caixa.text='Velocidade = ' + str(int(bola.velocity.y)) + " m/s" caixa2.text='Aceleracao = ' + str(int(a.y)) + 'm/s^2' if bola.y<10: a=vector(0,(peso+impulsao)/m,0) if bola.y>10: a=vector(0,peso/m,0) if bola.yliquido.radius-bola.radius: break