I am trying to create a function that will generate a parabola that describes projectile motion.
Here are my inputs:
- The starting x-y coordinate of the throw
- The initial x-y velocity vector.
I need an output for an equation of a parabola that fits this motion.
By Newton's second law $F = ma = m(0,-g)$, which es equivalent to the set of equations: \begin{align} \ddot x(t) &= 0\\ \ddot y(t) &= -g. \end{align} After integrating these, we get that: \begin{align} x(t) &= x_0+v_{x}t\\ y(t) &= y_0+v_yt-\frac{gt^2}{2}, \end{align} where $(x_0,y_0)$ is the initial position of the object and $(v_x,v_y)$ its initial velocity. These equations define a parabola.
If you want to get an equation of the form $y = f(x)$, use that $t= \frac{x-x_0}{v_x}$, then: $$ y = y_0+v_y\frac{x-x_0}{v_x} - \frac{g(x-x_0)^2}{2v_x^2}, $$ where $x\in[x_0,x_1]$ and $x_1$ is where the projectile reaches the ground again.