I am building a game, where I have to plot a trajectory of a ball in 3D space, launched with an inital velocity Sx, Sy, Sz. [I am using OpenGL and Android-NDK]

Lets assume Sz is always 0. And Sx and Sy values are known.

Now, I am able to plot a dotted trajectory properly along the path taken by the ball, under uniform gravity. But, the problem is that the distance between the points are NOT EQUIDISTANT, since I am plotting them at regular time intervals.

So, the next step for me is to plot the trajectory at intervals (tn) such that my distance traveled (d) is always fixed.

Now, assume I want to plot the "nth" trajectory point for every "d" units of distance. So, I need 'tn' to plot it.

I have tried solving this on white board, but the resulting equation for 'tn' is too complex. And I could get this far :

d^2 = dx^2 + dy^2;

dx = Sx * t; | t = dx/Sx;

dy = Sy * t + 1/2 (g) (t^2); | dy = Sy * (dx/Sx) + 1/2 (g) ((dx/Sx)^2);

So t = 'gives me an equation that has a highest order of 4';

I am hoping there must be a better way. Can anyone please help me derive a better equation for 't'.

Time (tn) = ?; Assume tn = Tn - T(n-1); Where 'Tn' is total time to cover 'n' times 'd' units of distance.

In terms of : 'd' : is distance interval. (fixed); 'sx': initial velocity along x axis (horizotal ground); 'sy': initial velocity along y axis (against gravity 'g');

Hope, I made thing clear enough. Please let me know if you need more information.

I tried this question in 'physics.stackexchange.com', but I was thinking this might be a more appropriate place to discuss, since I want a perspective of a game developers too.


2 Answers 2


Or, if you don't mind a slightly less pure, but much simpler and good-enough-for-visualisation approach:

Use an approximation to the arc, by connecting points on it with straight lines. Calculating points on this path that are equidistantly spaced should be relatively trivial.

  • \$\begingroup\$ +1 for this idea.. since, at least visually, it should be more pleasing since the user doesn't see the intermediate (non-linear) parabola arcs and cannot judge their actual length. All the user has to do is to compute the intersection of a parabola with a sphere, where the center of that sphere is in one of those trajectory dots. More maths.. \$\endgroup\$
    – teodron
    Jul 12, 2012 at 13:57
  • \$\begingroup\$ Yup, I tried this approach! Its the way my current plotting happens. :-) The problem here is that my "draw_frame" from the gameloop is not guaranteed to be called at a fixed interval and the interpolated points seem a little off when the density of points increase. This happens when the ball is launched with high initial velocities. However, I might be able to tune it a little more by some trial and error. I will give it another shot. Thanks! \$\endgroup\$ Jul 12, 2012 at 16:13

Well, let's try it in 3D:

Assume the dynamics equation: r(t) = r0 + v0 * t + 0.5*g* t^2 where r is the position vector, v0 is the initial launch velocity and g is the gravitational constant acceleration vector (0,0,-9.8) .

Now let's analyze the length functional: L(t) = Integral(0,t, ||r'(t)|| dt) . This means that the total curve length from its beginning (t=0) till this t time instance is L(t). In this formula, ||r'(t)|| is the norm of the time derivative of the position function r(t). We know that the norm is actually the square root of the dot product of its argument vector:

||r'(t)|| = sqrt(dot(r'(t),r'(t)) hence you can analyze this amount:

r'(t) = v0 + g * t and therefore dot(r'(t),r'(t)) = v0ov0 + 2*v0og*t + gog*t^2 where o is the dot product operator (some write it as an angular bracket < a , b >, others use a dot which I tried to imitate here with this o). This dot product, in your case, is a quadratic function of t with nothing more than scalar coefficients in the name of those dot products. Hence, if you can compute a primitive for this sqrt(dot(r'(t),r'(t))=sqrt(at^2 + bt + c) where a=gog, b=2v0og, c=v0ov0 you're on the right path.

Call this primitive F(t), then L(t) = F(t) - F(0). If you want to know what t0 instance corresponds to a length on your path of d0 units, then just compute the inverse of L(t) by, what else, computing the inverse function of F(t).

as I am in a hurry, I can't compute the primitive, nor its inverse for you, but if you can't either, do it numerically (numerical integration and then numerical equation solving via Newton's method).

Later edit: Use the Wolfram Alpha to find the integral, then perhaps solve numerically for its inverse.. or again Wolfra Alpha

  • \$\begingroup\$ Thanks for the answer! I think I understood your concept. :-) I am working on it. Will get back once I get to solve it. Cheers! \$\endgroup\$ Jul 12, 2012 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .