Trajectory Diagram for the following situation:
 
This app automates constructing a trajectory diagram, which allows you to predict any object's trajectory if you know its acceleration as a function of time, the object's position, and/or its velocity. [See chapter N3 of Unit N in the Six Ideas That Shaped Physics series of introductory texts (3nd ed., McGraw-Hill, 2017) to learn how to construct such diagrams by hand.]
Pressing the "Setup" button displays a dialog that allows you to specify the time step (and units),
the plane of the object's motion (the xy or xz plane), the object's initial position vector
(and units),
and its initial velocity vector (either in terms of components or as a magnitude and an angle from the
x axis). You can also specify the object's acceleration as the sum of five terms, one in the
+x direction, one in the +y (or +z) direction, one in the direction pointing radially
away from the object's current position, one pointing "forward" (in the direction of the object's
current velocity), and one pointing "sideward", that is, in the direction perpendicular to the object's
velocity, to your left if you stand on the plane of motion and look forward along the the velocity
(useful for modeling lift or magnetic forces.) You do this by typing a mathematical expression to
calculate each term at each step in terms of the current time t
, the object's current position
coordinate x
and y
(or z
), the current distance r
the object is from the origin, its current velocity components vx
and vy
(or vz
), and/or its current speed v
. See the bottom of these notes
for more information about how to format the mathematical expressions. You can also use the "Cases"
menu to quickly set up one of a number of interesting physical cases.
Once you have dismissed the "Setup" dialog, you will see the initial velocity vector displayed on the graph. Pressing the "One Step", "5 Steps, "20 Steps" or "50 Steps" button will construct the specified number of steps for the diagram. Pressing the "Step Back" and "Step Back 5" buttons erase the specified number of steps. The "Reset" button restores the graph to the specified initial conditions. The "Overview" radio button shows all steps of the trajectory, while the "Last Step" button shows how the last step was constructed (as well as providing some numerical data). You can also draw a rectangle on the graph to focus in on a certain region (doing will automatically set the "Custom" radio button). Clicking on that "Custom" button directly will zoom out a bit. These last two features allow you to quickly inspect any region you choose.
You can use your browser's "Print" function to print the page, but on some browsers, you may have to make the page smaller to see the full graph: be sure to check the print preview before you print. A more foolproof method is to take a screen shot of the browser window and print that.
Version 5.0 adds to first Javascript version (4.0) the capabilities of varying the window size and choosing regions to view. I have tried to make this app as simple and user-friendly as possible. The practicalities of the web-based version required some changes in the user interface from the last desktop-based version (the version described in the text), but for the most part, I think that these changes have made the program more useful and transparent. Please send me bug reports or feature requests via "Contact" form on the website. You may also examine the Javascript code by simply looking at the page source.
While this program is not really designed to model one-dimensional motion, one can do this by defining the object's initial velocity in, say, the y direction to be, say 1.0 m/s, and then setting only the x component of the acceleration. Since the object's y-velocity will be constant, this will essentially make the y axis a time axis.
Please note the following when entering mathematical expressions into acceleration boxes in the setup
dialog. The variables x, y, t, r, v, vx, vy,
and pi
are automatically defined
and can be used in any expression (if you have set the plane of motion to be the xz
plane, z
and vz
are defined instead of y
and vy
).
Valid operators are +
(addition), -
(subtraction), *
(multiplication), /
(division), and ^
(raising to a power). Some examples of
valid expressions are
2*pi*r
sqrt(x^3)
(vx^2 + vy^2)/3
cos(2.3*t)
The usual rules of precedence of operations apply: for example in the expression a+b*c^-(d+e)
,
the quantity (d+e)
is evaluated first (because it is in parentheses), the result is then
negated, the value of c
is then raised to that power (since powers have precedence over
other operations), the result is then multiplied by b
(because multiplication and division
take precedence over addition and subtraction), and finally a
is added to the result.
The following is a list of the functions that one can use:
pow(x,y)
is equivalent to x^y
deg(x)
converts x
in radians to degreesrad(x)
converts x
in degrees to radiansexp(x)
is the exponential functionlog(x)
is the natural logarithm functionsin(x), cos(x),
and tan(x)
all take arguments in radiansasin(x), acos(x),
and atan(x)
are inverse trig
functions, which return results in radiansceil(x)
returns the next integer above (less negative than) x
floor(x)
returns the next integer below (more negative than) x
frac(x)
returns the fractional part of x
(e.g. frac(-2.51)
= 0.51)rnd
returns a random number between 0 and 1min(x,y)
returns x
if x < y
,
or y
if y < x
max(x,y)
returns x
if x > y
,
or y
if y > x
mod(x,y)
returns x
mod y
sinh(x), cosh(x),
and tanh(x)
are hyperbolic trig functionsasinh(x), acosh(x),
and atanh(x)
are inverse hyperbolic trig functionsSetup for a run based on case:
Expressions in the acceleration boxes can include numerical constants and/or the variables x, y, z (position components), r (distance from the origin), t (time), v (speed), vx, vy, and/or vz (velocity components).
Trajectory Diagram for the following situation: