Soccer ball dynamics

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
MrMonk
Posts: 2
Joined: Thu Aug 05, 2010 12:39 pm

Soccer ball dynamics

Post by MrMonk »

Hi all

I decided to play a bit with the bepu library and as my first exercise I want to simulate the behaviour of a soccer ball. This will also help me to (re)learn some physics concepts.
When a force is applied away from the center of mass, the ball will travel in a curve while in the air. I believe in bepu this is achieved by using the applyRotationalImpulse function on the ball...but how to find out exactly where you kick the ball? How do you determine the angle the ball curves while in mid air?

Thanks :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Soccer ball dynamics

Post by Norbo »

how to find out exactly where you kick the ball? How do you determine the angle the ball curves while in mid air?
To decide where to kick, there's quite a few options. For gameplay, the more faked it is, the better it probably will be. You could use raycasts from some backward position towards the ball to determine the 'kick point' to apply impulses at.

That said, imparting an angular impulse will not cause the ball to curve in mid-air. Curving comes about from aerodynamics ("magnus force"), which is out of scope for normal rigid body physics. You can fairly simply simulate the behavior of curving based on the linear/angular velocity, though: http://en.wikipedia.org/wiki/Magnus_effect

Note that angularVelocity represents the the axis of rotation * angular speed in radians. That's why crossing the linear velocity with angular velocity gets you a vector that points in the right direction.

As far as what parts of the entity can help you work on this, check out the internalLinearVelocity and internalAngularVelocity properties, as well as the associated momentum properties, and applyImpulse/applyLinearImpulse/applyAngularImpulse. The applyImpulse method takes an impulse and location at which the impulse is applied, which automatically computes and applies the angular impulse.

There's a common misunderstanding that you might run into as well: applying an impulse of magnitude X away from the object's center of mass will still change the object's linear momentum by X, instead of less than X. The angular momentum change is different depending on the offset from the center of mass.
MrMonk
Posts: 2
Joined: Thu Aug 05, 2010 12:39 pm

Re: Soccer ball dynamics

Post by MrMonk »

Thank you Norbo :)
Post Reply