Skip to content
Snippets Groups Projects
Commit 7cb1ba8a authored by Prannesh SathyaMoorthy's avatar Prannesh SathyaMoorthy
Browse files

Upload New File

parent a3e54d6c
Branches
No related tags found
No related merge requests found
from vpython import *
#GlowScript 2.7 VPython
ball = sphere(pos=vector(-5,0,0), radius=2.5,color=color.green)
wallR = box(pos=vector(6,0,0), size=vector(0.2,12,12), color=color.blue)
ball.velocity = vector(25,0,0)
deltat = 0.005
t = 0
ball.pos = ball.pos + ball.velocity*deltat
wallL = box(pos=ball.pos, size=vector(0.2,12,12), color=color.red)
ball.velocity = vector(25,5,0)
vscale = 0.1
varr = arrow(pos=ball.pos, axis=vscale*ball.velocity, color=color.yellow)
while t < 3:
rate(100)
if ball.pos.x > wallR.pos.x:
ball.velocity.x = -ball.velocity.x
ball.pos = ball.pos + ball.velocity*deltat
t = t + deltat
wallL = box(pos=ball.pos, size=vector(0.2,12,12), color=color.red)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment