Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


soccer ball physics+math


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 AticAtac   Members   -  Reputation: 334

Like
0Likes
Like

Posted 30 July 2012 - 05:25 AM

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 ....

Sponsor:

#2 Inferiarum   Members   -  Reputation: 733

Like
0Likes
Like

Posted 30 July 2012 - 05:49 AM

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.

#3 AticAtac   Members   -  Reputation: 334

Like
0Likes
Like

Posted 30 July 2012 - 06:45 AM

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.

#4 SimonForsman   Crossbones+   -  Reputation: 6655

Like
0Likes
Like

Posted 30 July 2012 - 08:56 AM

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)
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#5 AticAtac   Members   -  Reputation: 334

Like
0Likes
Like

Posted 30 July 2012 - 09:42 AM

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).

#6 Álvaro   Crossbones+   -  Reputation: 15260

Like
0Likes
Like

Posted 30 July 2012 - 09:48 AM

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.

#7 AticAtac   Members   -  Reputation: 334

Like
0Likes
Like

Posted 31 July 2012 - 02:17 AM

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.

#8 SimonForsman   Crossbones+   -  Reputation: 6655

Like
0Likes
Like

Posted 31 July 2012 - 07:00 AM

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.


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.
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS