We will make an animated picture of our particle moving around inside a box before collision with the walls.
Motion of a Classical Particle in a Box
Motion of a Classical Particle in a Box
June 20, 2017—Bhubanjyoti Bhattacharya
Make the Particle and Walls
Make the Particle and Walls
The first step is to create a box and a point with given coordinates within the box.
Make a :
In[]:=
mybox[mx_Integer,ny_Integer]:=Graphics[Raster[ConstantArray[1,{ny,mx}]],FrameTrue,FrameTicksNone];mybox[20,10]
Out[]=
Make a with a dot:
In[]:=
mybox[{mx_Integer,ny_Integer},{px_Integer,qy_Integer}]:=Graphics[Raster[ReplacePart[ConstantArray[{1,1,1},{ny,mx}],{qy,px}{1,0,0}]],FrameTrue,FrameTicksNone];mybox[{20,10},{5,5}]
Out[]=
Make a simple animation of this before collisions with a wall:
In[]:=
Animate[mybox[{20,10},{u,v}],{u,5,8,1},{v,5,8,1},AnimationRunningFalse]
Out[]=
Build the above into a single function:
In[]:=
myAnimatedbox[{mx_Integer,ny_Integer},{x0_Integer,y0_Integer},{vx_Integer,vy_Integer}]:=Animate[mybox[{mx,ny},{u,v}],{u,x0,mx,vx},{v,y0,ny,vy},AnimationRunningFalse];myAnimatedbox[{20,10},{5,5},{1,1}]
Out[]=
Make the animated box more uniform using a single parameter (time):
In[]:=
mytimeAnimatedbox[{mx_Integer,ny_Integer},{x0_Integer,y0_Integer},{vx_Integer,vy_Integer}]:=Animatemybox[{mx,ny},{x0+vxt,y0+vyt}],t,0,Min,,1,AnimationRepetitions1;mytimeAnimatedbox[{20,10},{5,5},{1,1}]
mx-x0
vx
ny-y0
vy
Out[]=
What Happens after Collision with a Wall?
What Happens after Collision with a Wall?
Examples of the Final Animated Graphics
Examples of the Final Animated Graphics
Can We Make This Work in Three Dimensions?
Can We Make This Work in Three Dimensions?
Examples of the Final Animated Graphics in 3D
Examples of the Final Animated Graphics in 3D
Ideas for Things to Do in the Future (Future Explorations)
Ideas for Things to Do in the Future (Future Explorations)
AUTHORSHIP INFORMATION
Bhubanjyoti Bhattacharya
6/20/17