How can I get the movement path of the body before it moves?

I find an iphone&android game has the feature that I need.
Image

The game use the box2d, but I dont't know how to implement it.

http://www.ellismarkov.com/
cruel wrote:
From the two formula
x = vx * t
y = vy * t - 1/2 * g * t^2
I get the forumla "y = vy/vx * x - 1/2 * g *x^2 / vx^2".


Ah, ok, right on, that's correct at all times, sorry, I misinterpreted what you were solving for (I thought x and y here were at the vertex of the parabola).

You're not done yet, though, because you still need to solve that expression for the maximum to find the peak (err, vertex, if we're using proper terminology). Which means we just set dy/dx = 0 and see what falls out:

dy/dx = vy/vx - g x(peak) / vx^2 == 0
=>
vy/vx = g*x(peak)/vx^2
vy = g*x(peak) / vx
or
x(peak) = vy * vx / g
(which, thankfully, matches the expression I gave earlier - always good to double check these things).

From there, you proceed as I mentioned, plugging in that x value to the y expression and simplifying.

This still assumes, of course, that you're setting the parameters based on the desired vertex of the parabola.
ewjordan wrote:
Ah, ok, right on, that's correct at all times, sorry, I misinterpreted what you were solving for (I thought x and y here were at the vertex of the parabola).

You're not done yet, though, because you still need to solve that expression for the maximum to find the peak (err, vertex, if we're using proper terminology). Which means we just set dy/dx = 0 and see what falls out:

dy/dx = vy/vx - g x(peak) / vx^2 == 0
=>
vy/vx = g*x(peak)/vx^2
vy = g*x(peak) / vx
or
x(peak) = vy * vx / g
(which, thankfully, matches the expression I gave earlier - always good to double check these things).

From there, you proceed as I mentioned, plugging in that x value to the y expression and simplifying.

This still assumes, of course, that you're setting the parameters based on the desired vertex of the parabola.


I got it.

Use the ewjordan's formula:
Code:
vy/vx = g*x(peak)/vx^2
vy = g*x(peak) / vx

I calculated the vx and vy.Using vx and vy, I got the x and y value of each time step.So I can draw the parabola curve.

And setting the body's lineDamping to zero, the body will follow thep arabola curve to move.

Thank you,ewjordan.
And thank you all your guys.

There is another question:how to create a hollow body, such as a empty circle ?
cruel wrote:
There is another question:how to create a hollow body, such as a empty circle ?

You would need to define the perimeter with multiple, separate shapes (line segment shapes would be the logical choice, if you're using a version of Box2D that supports them).
Jesse wrote:
You would need to define the perimeter with multiple, separate shapes (line segment shapes would be the logical choice, if you're using a version of Box2D that supports them).


Thank you.Is there having any example?
Quote:
Is there having any example?

There's not that much to it; if you know how to create shapes, fixtures, and bodies, then you already know most of what's required.

To create a circle, you'd want to choose a subdivision level that provides a good tradeoff between accuracy and efficiency (in the sense of not creating too many fixtures), and then use simple trig to compute the vertices. Each edge of the (approximated) circle would consist of a single two-vertex polygon (assuming you're using a version of Box2D that has this feature).

If you're still not sure how to do it, perhaps you could clarify what part you're having trouble with.

Original thread: https://box2d.org/forum/viewtopic.php?t=5288