maTeionE best viewed with NetSurf 
My programs  Games  Other programs  
GNU/Linux  Computers & programming  Music & movies  
Other topics  What's new + README  Contact  
  
Games, C & SDL
Skunks
SimCar
JavaScript
Game with cannon

Updated 20231104 Game with cannon Play Download The game was tested in Mozilla 1.4.1 from 2003 and should function in almost any browser that supports JavaScript. MD5: 4767079b33cc8726b1b31224124f2d8b Mathematical relations If the position of the cannonball at time t is described by vector r(t) = (x(t) y(t))^{T}, then the velocity v(t) and the acceleration a(t) are expressed by Equations (1) and (2): dr(t) v(t) =  (1) dt dv(t) d^{2}r(t) F(t) a(t) =  =  =^{ } (2) dt dt^{2} mIn this case, the force F depends on the velocity of the particle: F(v(t)) = G + R(v(t)); G = m·g R(v(t)) = k·(v(t)  v_{w})·v(t)  v_{w} (3)where g is the gravitational acceleration, G is the weight, R(v(t)) is the air's resistance (drag), v(t) is the speed of the particle and v_{w} is the wind speed. Equation of motion (2) can be solved numerically, which usually means finding r(t) and v(t) at t_{1}, t_{2}, t_{3},...,t_{i}, t_{i+1},..., where t_{i+1} = t_{i} + Δt. Some methods are exemplified below. r(t_{i+1}) = r(t_{i}) + v(t_{i})·Δt v(t_{i+1}) = v(t_{i}) + a(t_{i})·Δt (4)Equations (4) are known as Euler's method and are used here. r(t_{i+1}) = r(t_{i}) + v(t_{i})·Δt + a(t_{i})·(Δt)^{2}/2 (5)Equation (5) is called the SUVAT method and is used in SimCar. The equations for the case in which the acceleration is considered to have a linear variation between t_{i} and t_{i+1} can be found in file Equations.pdf from Cannon.zip, in my PhD thesis on pages 76 and 77, and in file doc/doc.pdf from mtfem2.0.0.tar.gz, on pages 18 and 19. The methods presented so far are based on Taylor polynomials, but Verlet's method, suitable for computing trajectories of planets and other particles moving in various force fields, uses a slightly different approach (see Equations.pdf).


 