# How to simulate the movement of a ball in 2D due to force, gravity, and friction with surface?

I have a ball which I kick with some force. It has a starting x,y position, sat (2,3) and an intended target x,y say (7,8) position. That means I have to translate by (7-2, 8-3) i.e. 5 x units and 5 y units to reach destination.

The things acting on this ball are

force of kick(in direction of target), gravitational pull towards floor due to mass, and friction force provided by grass.

I will experiment different values of the 3 and see which one best simulates. But how do I calculate time required to destination and how much to translate in every frame of my game?

Can anybody please give me an equation for displacement due to these 3 factors and how velocity and other factors required in the equation change with time elapsed?

• hyperphysics.phy-astr.gsu.edu/hbase/hph.html#mechcon This is a general physics question. If you write out the kinematic equations (set of few linear/quadratic equations) for this you should be able to easily transfer them into code.
– mobo
Aug 1 '13 at 5:37
• I would also look at linear algebra. If you want to make/use a physic engine you need to use it. blog.wolfire.com/2009/07/…
– mobo
Aug 1 '13 at 6:26
• You could include air resistance / aerodynamics for the most real result. Aug 1 '13 at 15:20
• how to do that? Aug 1 '13 at 16:21

The ball has a kinetic energy of: when kicked.

The force pushing the ball down to the ground can be ignored, since a ball is round, it rolls (doesn't slide), so there's no static friction.

The force of the grass cannot be ignored. And, in this case, essentially acts like static friction, like a block sliding on the ground would encounter friction from the floor, a ball rolling on the grass encounters friction from the grass. We want to know how far the ball will go. Which means we want to know when the kinetic energy of the ball is zero. We want the amount of work done to negate the kinetic energy of the ball we found in the first equation (so we set our equation equal to the negated amount and solve). The amount of work done by friction to stop the ball can be found with: Solving for distance gives us: Now that you have the distance, the time can be found with this answer.

However, there are a few options for simulating the movement of the ball in game. One of them could easily lead to you not getting the distance defined by the formula above.

If you're simulating the physics with an iterative approach, your final result will be different (unless your time step is crazy small, you'll have large enough errors to notice). This is similar to the differences you'd get in a Riemann sum estimation vs integration.

An iterative approach is very common in games. But if you're looking for accuracy, you can use the physics equations above and calculate the position of the ball based on the time since the simulation started. The equations for calculating the position since the start of the simulation can be the equations for constant linear acceleration. Since the forces acting on the ball are constant throughout (friction of the grass).