

g =  9.8  # m/s^s 
a = -g
v0 = 10 # m/s

tM = 2*v0/g

t  = 0  # s
y0 = 0

plot(t, y0, xlim=c(0, tM), ylim=c(0, v0^2/(2*g)*1.05),  xaxs='i',  yaxs='i',
     xlab='t (s)', ylab='y (m)', pch=19, col='blue',
     main="Equazione oraria (y vs t)   [v0(m/s): 10, 9, 8, 7 , 6, 5]" )

Dt = 0.02 # s

while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='blue')
  if(t > tM) break
}

#----------------------------------------------------------
Sys.sleep(1)
v0 = 9.0 # m/s
t  = 0  # s
points(t, v0 + a * t, pch=19, col='gray')
while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='gray')
  if(t > tM) break
}

#----------------------------------------------------------
Sys.sleep(1)
v0 = 8 # m/s
t  = 0  # s
points(t, v0 + a * t, pch=19, col='gray')
while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='gray')
  if(t > tM) break
}

#----------------------------------------------------------
Sys.sleep(1)
v0 = 7 # m/s
t  = 0  # s
points(t, v0 + a * t, pch=19, col='gray')
while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='gray')
  if(t > tM) break
}

#----------------------------------------------------------
Sys.sleep(1)
v0 = 6 # m/s
t  = 0  # s
points(t, v0 + a * t, pch=19, col='gray')
while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='gray')
  if(t > tM) break
}


#----------------------------------------------------------
Sys.sleep(1)
v0 = 5 # m/s
t  = 0  # s
points(t, v0 + a * t, pch=19, col='cyan')
while(1) {
  Sys.sleep(Dt)
  t = t + Dt
  points(t, y0 + v0*t + a/2 * t^2, pch=19, col='cyan')
  if(t > tM) break
}

