# Predicting projectile peak based on vector points

hey folks, I am making a program that uses object tracking to watch a juggling pattern and plays notes based on the peaks of the balls. I want to predict when/where(x,y) a peak will happen before it does and what i have to work with is when/where(x,y) the ball appears in each frame. I have looked around a bit online, but physics is so foreign to me and I am having some trouble. Here is a sample problem:

FRAME #1

time = 0.00, x = 10, y = 10

FRAME #2

time = 0.05, x = 12, y = 16

I just made these figures up, but is this enough information to determine the balls trajectory? or do I need a FRAME #3? if it is enough, then what formula do I use to get the position/time of the peak?

Any help whatsoever would be so greatly appreciated, let me know if this doesn't make sense and I will re-explain. Thanks!

So now that I have this typed up, I think I may have just had an epiphany. I may be off on this, but in the real world the force of gravity is (9.81 m/s2), however, in order to take gravity into account here I need to have a gravity force that is in pixels, not meters. I am not sure but it seems like in order to do the conversion from meters to pixels, I need to take into account the distance I am away from the camera, right?

This conversion may be simple though, say i am working with a camera that has a pixel height of 100, and i hold a tape measure up when I am, say 5(i think this number is irrelevant) meters away from the screen and i find that at this distance the camera can see exactly 2 meters of my tape measure.

then it seems like to find my gravity effect at this range all i would need to do is
100pixels = 2m
Zpixels/s^2 = 9.81m/s^2

where Z = gravity in pixels
and in this case Z = 490.5

Can anyone confirm that this makes sense?

Last edited:
If you only have two frames, you need to figure out the value of g in pixels per second squared. If you have three frames, however, it can be computed from the data.

• 1 person
Holy cow, that was fast! thank you so much voko!

Allright, so here are 3 actual values(pulled off a chart i found since my object tracker is not precise enough yet), what info do i need to extract from them, or what equation would i plug them into?

(t,x,y)
(0.05, 0.2, 0.13775)
(0.1, 0.4, 0.251)
(0.15, 0.6, 0.33975)

It is really great to hear that this is possible, i was initially told that i would probably need the depth sensor of a Kinect to do this, but i really want to avoid that, it looks like i will be able to. Thanks again!

The basic equation for vertical motion is ## y = y_0 + v_{y0} t - gt^2 / 2 ##. When you use the data from the three frames, you have $$y_1 = y_0 + v_{y0}t_1 - gt_1^2/2 \\ y_2 = y_0 + v_{y0}t_2 - gt_2^2/2 \\ y_3 = y_0 + v_{y0}t_3 - gt_3^2/2$$ where you know ## t_1, \ y_1, t_2, \ y_2, \ t_3, y_3 ## and ## v_{y0} ## (initial vertical velocity), ##y_0## (initial height) and ##g## (acceleration due to gravity) are to be determined. Solve the system for the unknowns.

Once you have them, the time for max height is given by the equation ## v_{y0} - gt = 0 ##, and the height at that time is given by the very first equation in this message.

• 1 person
Thanks voko!

You say that initial height is to be determined, but would it not just be 0? if not, and it is an unknown then won't that always leave me with an unknown since I can't solve equations with 2 unknowns(or can I?)

I tried leaving (Yo) as an unknown and plugged my variables into the middle 3 equations you gave me, but I don't know, it just looks like an inconsistent mess to me. I don't know what I am doing, I get a bunch of different values for (g). I am really out of my league here, do you know what it is I should read up on to help me grasp this?

0.13775 = Yo + (0.13775/0.05)(0.05) - [g(0.05)(0.05)]/2

0.13775 = Yo + 0.13775 - 0.00125g
0.00125g = Yo
g = Yo/0.00125

0.251 = Yo + (0.13775/0.05)(0.1) - [g(0.1)(0.1)]/2

0.251 = Yo + .2755 - .005g
-0.0245 = Yo - .005g
.005g = Yo + 0.0245
g = (Yo/.005) + 4.9

0.33975 = Yo + (0.13775/0.05)(0.15) - [g(0.15)(0.15)]/2

0.33975 = Yo + .41325 - 0.01125g
-0.0735 = Yo - 0.01125g
0.01125g = Yo + 0.0735
g = (Yo/0.01125) + 6.53333333333

Khashishi
If you are working with real data, you need an algorithm that is robust against noise. In theory, three points determines a parabola, but you probably want to take more than three points and find a best fit parabola, using least squares or maybe a more robust algorithm.

Thanks voko!

You say that initial height is to be determined, but would it not just be 0?

I do not know enough about your problem to say that ##y_0 = 0 ## (or not). If you are completely sure that is the case, then you can drop it from the equations; and then you will only need two equations (two frames) to determine ##v_{y0} ## and ##g##. Khashishi is certainly correct stating that more data can be gainfully employed, but that also means more complex algorithms, which, given your difficulty with the basic linear equations might be more than you can chew.

I am really out of my league here, do you know what it is I should read up on to help me grasp this?

What you need here is some theory and practice in solving systems of linear algebraic equations. Here is a link: http://en.wikipedia.org/wiki/System_of_linear_equations