This program draws a 2D motion plot from an initial starting point (x, y) given initial velocity and acceleration. The rate and direction of both velocity and acceleration are assumed to be constant.
x(t) = ax * t^2 / 2 + vx * t + x0 y(t) = ay * t^2 / 2 + vy * t + y0
where t = number of seconds.
The script uses math and matplot.pyplot modules.
from math import * from matplotlib.pyplot import * # 2024-07-23 EWS print("Motion Plot per second from (0,0)") c=eval(input("init. x position? ")) d=eval(input("init. y position? ")) a=eval(input("init. x velocity? ")) b=eval(input("init. y velocity? ")) v=eval(input("acceleration x? ")) u=eval(input("acceleration y? ")) n=int(input("number of seconds? ")) x=[v*t**2/2+a*t+c for t in range(n)] y=[u*t**2/2+b*t+d for t in range(n)] x0=min(x)-1 x1=max(x)+1 y0=min(y)-1 y1=max(y)+1 axis((x0,x1,y0,y1)) text(x0,y1-1,"Motion Plot") plot(x,y,'gray') scatter(x,y,color='blue',marker="h") scatter(x[0],y[0],color='green',marker="h") show()