# Calculating distance by force

I am trying to predict a ball(sphere) movement. The formula of force which I know is

Force=Mass*Accelaration


What I want is how can I get distance or displacement by giving particular force? I want to consider drag, angular drag and friction also included in the equation. Or if it can be vice-versa, calculating force needed by providing distance.

The equation I could find doesn't include drag and friction, thus they are not as accurate as I needed. Any help in generating the exact formula would be appreciated.

• Assuming Force to be a vector, couldn't you apply friction to the vector and then calculate its length? The vectors in unity come with a length function. – Sidar Jul 23 '13 at 13:05
• Actually drag plays major role than friction here. Although I am keeping everything constant, and varying force to calculate distance and vice-versa. – noob Jul 23 '13 at 13:09
• Yep, physics stackexchange would be a good fit here. If you use energy you can solve this fairly easily. You're adding energy with your initial force to get the object moving, then you're subtracting energy through friction at a known rate. You just need to calculate how much work (force over distance) is done to return the energy to zero. Also note that you won't be really applying any friction from the ground here, since you have a rolling ball, all you're going to have is drag. – MichaelHouse Jul 23 '13 at 13:35
• The choice is yours. – MichaelHouse Jul 23 '13 at 14:04
• There's static and dynamic friction.. and there's drag.. and drag's usually approximated as -b*b*velocity or as -b*velocity. In this case, you can say good-bye to linear equations and embrace ordinary differential equations.. see if you can get around these pieces of info: people.math.gatech.edu/~weiss/pub/V2I.pdf riotstories.co.uk/science/… they involve a projectile, but the sphere should be similar. – teodron Jul 23 '13 at 15:34

The Force and Acceleration components in that equation are actually vectors (2D vectors in 2D space and 3D vectors in 3D space). It can be rewritten as (forgive my lack of math notation)

sum(force_vectors) = mass * acceleration_vector


Let's consider you're working in a 3 dimensional game. We'll define the forces present according to your question

v_drag
v_angular_drag
v_friction
v_gravity
v_push (a force exerted by something else on this object)


All of those are 3D vectors in the form of { f_x, f_y, f_z } where every component is the component of the resulting force along the corresponding axis. In that case,

sqrt(f_x^2 + f_y^2 + f_z^2) = force_scalar

according to the Pythagorician theorem.

Now, your Force expression in your equation becomes

v_drag + v_angular_drag + v_friction + v_gravity + v_push


where + is obviously a component-wise vector sum. At this point, since you know the mass of your object you can calculate the vector of it's acceleration using

v_acceleration = Force / Mass


That vector represents the variation of your objects velocity. Let's say your object is at rest (velocity = { 0, 0, 0 } m/s) at position { 0, 0, 0 }. Its velocity at time = t is expressed as

velocity = initial_velocity + t * acceleration


Likewise, its position is expressed as a function of its previous position, time and velocity. Therefore

position = initial_position + t * velocity


A crude implementation of such a physics simulation would then look like

PhysicsBody body;

while(true) {
float delta_time = get_time_delta();
float acceleration = (v_drag + v_angular_drag + v_friction + v_gravity + v_push) / body.Mass;
body.velocity += delta_time * acceleration;
body.position += delta_time * velocity;
}


Where delta_time is the time elapsed since your last physics update.

There are a few things wrong with this naive implementation, particularly that a long update time would render the whole calculation extremely imprecise. However, you'd need to get into some calculus to solve the related equations and I'll let someone more qualified than me get into that mess (although I don't think the question implied it needed to go into that much detail).

• That's a nice explanation. I'll try to add this in my game and let you know the findings. I am just trying to predict the ball movement, which is already simulated by Physics engine(Unity3D's Physx engine in my case). – noob Jul 23 '13 at 14:40
• @Creator That would probably have been a good thing to add to your question considering it changes everything. I have no idea how Unity simulates physics under the hood, there might be functions in there to achieve what you want and depending on the precision you need it might be very impractical to predict this. Your question then becomes "How can I predict body movements in Unity's Physx?" which is a whole different thing. – pwny Jul 23 '13 at 14:48