Sign in to follow this  

soccer ball physics+math

This topic is 1962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to simulate a soccer ball. I already know all the maths and physics (magnus effect, etc.).
Right now i have just an understanding problem with velocities:
the ball moves in a certain direction x,y (lets assume its not flying so no 3rd dimension) by having 2 velocities, each for x and y axis.
My problem is now that once the velocity in one direction gets zero (cuz of friction and other forces) the ball still moves on the other axis which then looks strange cuz it then starts to move only horizontaly/verticaly depending on which velocity gets zero.

Maybe someone could enlighten me ....

Share this post


Link to post
Share on other sites
You should not think of it as separate velocities. The velocity is represented by a vector, and in the most simple case, the acceleration due to friction etc. is pointing in exactly the opposite direction.

Share this post


Link to post
Share on other sites
Ok, let me get a little more precise:
I got a routine which calculates the ball movement with the typical math/physics equations and using an ODE solver (Runge-Kutta) to computer new ball position and velocities for a time-slice. So what i initially feed it in are, besides some other constant parameters, 6 parameters:
(x,y,z) - positions
(x,y,z) - velocities

It then updates the values for each iteration (which is also dependent on a time-slice).
I should say that these aren't my routines (lazy me), but from a physics-for-game-programmers book.
So far, the routines work great, except for the above problem.

I was thinking that the acceleration/velocity should be only one parameter (which is then damped by friction etc.) and this value is then used to move the ball, so the ball is always moving along its direction until it is stopped.
Somehow i am confused ...

I can provide the code if it will help.

Share this post


Link to post
Share on other sites
air friction on a round ball should be applied towards the velocity vector and be based on the velocity so it should be impossible for friction to zero out one component before the others, you aren't calculating/applying your friction force properly.

The other forces (gravity if the ball is flying or impact forces if the ball hits something) should be able to cancel out one component of the velocity vector before the others but that shouldn't look strange.

Also, remember that friction forces between the ball and the ground should be applied at the point of contact, not at the center of the object. (you want to get the ball rolling rather than sliding when its on the ground)

Share this post


Link to post
Share on other sites
Thanks for your comment.
I will check my routines. I am thinking about if i need an ODE solver or if i should go for an easier way.
I've also to distinguish between ball in air (projectile) and ball on the ground (ground friction) and also need to extend the routines for the ball to bounce (right now i use height_velocity = -height_velociry / 1.32).
The good thing about the routine i am right now using is that it gives me magnus-force, friction and air drag (also wind which i don't need).

Share this post


Link to post
Share on other sites
You should try to describe your Physics update in terms of vectors (and perhaps points and rotations), without any explicit reference to the coordinates. Then you will probably never see anything special about the directions of the axes.

Share this post


Link to post
Share on other sites
Thanks for the help.
The mistake i was doing was to check for each individual velocity to stop so i can prevent the ball moving too long (even slow).
What i am doing now is to check the magnitude of the velocity (sqrt(vx*vx+vy*vy+vz*vz)) for stoping the ball if it falls below a certain value.

Share this post


Link to post
Share on other sites
[quote name='AticAtac' timestamp='1343722642' post='4964758']
Thanks for the help.
The mistake i was doing was to check for each individual velocity to stop so i can prevent the ball moving too long (even slow).
What i am doing now is to check the magnitude of the velocity (sqrt(vx*vx+vy*vy+vz*vz)) for stoping the ball if it falls below a certain value.
[/quote]

if you are checking the velocity vectors magnitude against X you can skip the sqrt and check it against x*x instead for a performance boost (sqrt can be quite slow), If you are comparing the magnitudes of two vectors the gain is even bigger (as you can strip out the sqrt on both ends and don't have to add a multiplication to compensate) You should always work with the square of the magnitude when it is possible to do so.

Share this post


Link to post
Share on other sites

This topic is 1962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this