Message Boards Message Boards

[GIF] Toss (Projectile envelope)

Projectile envelope

Toss

Inspired by Example 5 from the Wikipedia article on "Envelope (mathematics)". Basically: if you throw a projectile from the origin with initial speed $v$ and initial angle $\theta$ subject to gravitational acceleration $g$, then its trajectory as a function of $t$ is given by:

Trajectory[t_, v_, g_, ?_] := {t v Cos[?], t v Sin[?] - g/2 t^2};

All such trajectories are tangent to the parabola $y=\frac{v^2}{2g}-\frac{g}{2v}x^2$, so the parabola is the envelope of the family of trajectories.

The animation shows a number of trajectories simultaneously, and the resulting envelope emerges without ever being explicitly drawn.

Note that the animation is not to scale: I've used AspectRatio -> 1 to scale the vertical axis to get proportions that work better for a square image. A more physically realistic animation is:

More realistic projectile envelope

The code is below, but I want to point out a couple of quirks. I originally used ParametricPlot rather than Graphics, which is conceptually simpler, but there seems to be a bug in the interaction of CapForm and ParametricPlot which makes it basically impossible to get endcaps to look right.

Consequently, I re-implemented the trajectories as a table of Lines, which mostly works okay, except that you can't really use transparency with concatenated lines unless you use CapForm["Butt"] or CapForm[None]: for example, with CapForm["Round"] the lines overlap, creating spots of increased opacity. This can make for a cool visual effect, but doesn't lend itself to a nice smooth gradient. Unfortunately, using CapForm["Butt"] leaves tiny gaps between the adjacent line segments, which I obscured by exporting the original GIF at 2160x2160 and then resizing down to 540x540.

Anyway, hopefully that explains most of the oddities in the code, which is not exactly speedy:

DynamicModule[{v = 1., g = 10., n = 101, timesteps = 75, transparencypoint = 3/2, pts, 
  cols = RGBColor /@ {"#393C83", "#C84771", "#FFE98A", "#280B45"}},
 pts = Join[
   Table[Trajectory[t, v, g, ?], {?, 0., ?/2, ?/n}, {t, 0., 2 v/g, 2 v/(timesteps*g)}],
   Table[Trajectory[t, v, g, ?], {?, ? + 0., ?/2, -?/n}, {t, 0., 2 v/g, 2 v/(timesteps*g)}]];
 Manipulate[
  Graphics[
   {Thickness[.004],
    Table[{
      If[i == s, CapForm["Round"], CapForm["Butt"]],
      Opacity[Min[1, transparencypoint + 2 (i - s)/timesteps]],
      Blend[cols[[;; -2]], (i - 1)/(Length[pts[[1]]] - 1)],
      Line[pts[[j, i ;; i + 1]]]},
     {j, 1, Length[pts]}, {i, 1, Min[s, timesteps]}]},
   ImageSize -> 540, PlotRange -> {6/5 {-v^2/g, v^2/g}, {0, 5/4 v^2/(2 g)}}, 
   AspectRatio -> 1, Axes -> False, Background -> cols[[-1]]],
  {s, 0, timesteps (1 + transparencypoint/2), 1}]
 ]
5 Replies

Great visualization! and splendid colors! (again!) Reminds me of https://www.youtube.com/watch?v=yR3qfXxqPF0 which I created using Mathematica 8 years ago (!)

POSTED BY: Sander Huisman

Oh wow, very cool. I love it!

enter image description here - Congratulations! This post is now a Staff Pick! Thank you for your wonderful contributions. Please, keep them coming!

POSTED BY: EDITORIAL BOARD

Hi Clayton,

What about the data ? Fireworks ! Bang ! Bang ! Bang !

I think you can see that natural phenomena are more three-dimensional and messier than your predictions.

Another thing, whenever you use Mathematica to calculate trajectories, you ignore a long history constrained by less sophisticated implements. It's useful to look at Harter's calculations, because he is the real lifetime master of all this. Around Lecture 25, he gets into compass and straight-edge construction for all sorts of envelopes, including the example of Rutherford scattering, which involves another conic section, the hyperbola.

In the past I have written mathematica notebooks showing the step-by-step construction of geometric diagrams. In this case, there are old methods of algebraic-geometry for constructing hyperbolas, parabolas, and ellipses. These techniques don't require Mathematica in the least. However, we can, and I think should, program the compass and straightedge geometry into Mathematica. This improves backwards-compatibility, which is important for research students.

Izidor Hafner has started on a project like this: Constructing Quadratic Curves, but I think Bill Harter's work is much more thorough and impressive, sets a higher standard. Mathematica programmers should be interested in following that direction.

Thanks,

Brad

POSTED BY: Brad Klee

I appreciate the pointers to Harter's and Hafner's work, but I think you're ascribing more seriousness to my post than was intended. My animation is obviously not a very accurate model of actual trajectories, but it does make for an interesting visual, which was the main goal.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract