Plotting a Parametric Line of Motion
07-26-2024, 02:14 PM
Post: #1
 Eddie W. Shore Senior Member Posts: 1,606 Joined: Dec 2013
Plotting a Parametric Line of Motion
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.
ax = acceleration in the x direction
ay = acceleration in the y direction
vx = initial velocity in the x direction
vy = initial velocity in the y direction

The HP Prime PPL program PLOTMOTION displays a traceable curve with a table of values.
The Numworks python script plotmtn.py uses math and matplot.pyplot modules. A scatter plot is laid on top of the path plot. The plot begins at the initial point where it is marked green.

HP Prime Program: PLOTMOTION

Code:
EXPORT PLOTMOTION()
BEGIN
// EWS 2024-07-22

LOCAL ch;
ch:=INPUT({C,D,A,B,V,U,N},
"Motion Plot Per Second",
{"x0:","y0:","vx:","vy:","ax:","ay:","n:"},
{"initial x position",
"initial y position",
"initial velocity x direction",
"initial velocity y direction",
"acceleration x direction",
"acceleration y direction",
"number of seconds"});

// user presses cancel
IF ch==0 THEN
KILL;
END;

// user presses OK
STARTAPP("Parametric");

'V*T^2/2+A*T+C'▶X1;
'U*T^2/2+B*T+D'▶Y1;
CHECK(1);

Parametric.Tmin:=0;
Parametric.Tmax:=N;
Parametric.Tstep:=1;

// table and plot
STARTVIEW(10);
STARTVIEW(9);
END;

Source

Tremblay, Christopher. Mathematics for Game Developers. Thomson Course Technology. Boston, MA. 2004. ISBN 1-59200-038-X.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)