# #Copyright (C) 2012 Mateus Valadas Preto Bravo Cordeiro #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* from visual.text import * #scene.fullscreen=1 g=-9.8 cb=0 cor='' v0y=0 v0x=0 x0=-25 a=0 y0=0 m=abs(float(input('Insira o valor da massa da bola (kg) '))) d=0 while d<4: d=abs(float(input('Insira o valor da distancia entre as placas (m) '))) if d<4: print("Insira um valor superior a 4") scene.range=(70,d+7,10) p=m*g print( "opções:\n 1- neutra \n 2- negativa \n 3- positiva") while cb<=0 or cb>3: cb = int(input ("Escolha o sinal da carga da esfera: ")) if cb==1: cor=color.white q=0 if cb==2: cor=color.blue q=abs(float(input('Insira o modulo do valor da carga pontual: '))) q=-q if cb==3: cor=color.red q=abs(float(input('Insira o modulo do valor da carga pontual: '))) print('Para a forca eletrica anular o peso, a ddp entre as placas tera de ter um valor de ',9.8*m/(q*d),' V') if cb<=0 or cb>3: print(" Escolha entre as opções 1, 2 ou 3") ddp=abs(float(input('Insira o valor da diferenca de potencial (V) '))) E=ddp*d while v0x<=0: v0x = float(input ("Velocidade Inicial (m/s)=")) if v0x <=0: print(" A velocidade inicial tem de tomar valores positivos\n Insira um valor positivo") CN= box(pos= (0,d/2,0), size=(50,2,30),color=color.blue) CP= box(pos= (0,-d/2,0), size=(50,2,30),color=color.red) positivo=text(pos=(0,d/2-0.5,15.1), axis=(1,0,0), width=1, height=1, string='PLACA NEGATIVA', color=color.white, justify='center') positivo=text(pos=(0,-d/2-0.5,15.1), axis=(1,0,0), width=1, height=1, string='PLACA POSITIVA', color=color.white, justify='center') ball= sphere(pos= (-25,0,0), radius=1, color=cor) ball.trail=curve(radius=0.25) dt=0.01 while true: rate (100) a=(E*q)/m+g x=x0+v0x*dt dx=x-x0 vy=v0y+a*dt y=y0+vy*dt dy=y-y0 x0=x y0=y v0y=vy ball.x=ball.x+dx ball.y=ball.y+dy ball.trail.append(ball.pos) if ball.x>25: E=0 if ball.y<-d/2+ball.radius+1 or ball.y>d/2-ball.radius-1: break