Search code examples
mathgeometrycomputational-geometrytrigonometryprojective-geometry

2D Projectile tracing path clarification


Projectile tracing path Problem in 2D game:

Assumption:

We make the simplifying assumption that gravity is constant and that there is no wind or drag. The motion of the projectile is given by the following equations:

x = x0 + v0t cos(theta)

y = y0 + v0t sin(theta) + .5 g t^2

where (x0, y0) is the initial position, v0 the initial velocity (magnitude only), theta the angle of discharge, and g the gravitational acceleration. Solving the first equation for v0t and substituting into the second, we get equation [1]:

y = y0 + (x-x0) tan(theta) + .5 (g/v0^2) (x-x0)^2 / cos(theta)^2

Calibration:

Calibration is the process of determining the value of g from an actual projectile. To do that, we shoot a random projectile and capture:

  1. The starting point (x0, y0)
  2. The aim vector (v0, theta)
  3. A random point on the curve (x1, y1)

Substituting the values into the equation [1] and solving for g, we get:

g = (v0^2) * {[2 cos(theta)^2 (y1-y0) / (x1-x0)^2] - [sin(2theta) / (x1-x0)]}

Application:

Now that we have g, we can substitute it back into equation [1], which now can be used to trace the path of a projectile from any starting point and initial velocity. (this is the part I don’t understand)

g=5.89

(x0,y0) starting position = 0,0

Initial velocity = 1-100

Discharge Angle = 0-360

can someone please explain how to get the full plotted path of the parabola for any initial velocity between 1-100, and for any discharge angle between 0-360, if the acceleration due to gravity is 5.89 (in this game), and the starting position is 0,0?

I am a complete newb at math, all of this stuff not in bold lettering I found elsewhere and have been racking my brain over. Please assume I know nothing.


Solution

  • Choosing v0 = 10 and theta = 60 degrees we have

    tan(theta) = 1.732
    cos(theta) = 0.5
    

    and thus equation 1 reads (x0=0, y0=0, g=5.89 were given)

    y = 1.732*x - 0.1178*x^2
    

    which can be plotted directly (y vs. x): see here

    Note: I corrected the - sign for gravity.