Golf ball collision response

Started by
6 comments, last by Paul7 20 years, 1 month ago
Am having difficulty in calculating the collision response between a golf ball and uneven ground. I want the rotation of the golf ball to have an affect as well as the friction between the ball and the ground. It describes how to do it in the physics for game developers book but feel its not explained very well and its more to do with collision between two objects with small masses. Maybe could adapt it but not sure how to do this when using a stationary object with a really big mass, ie the ground! Any suggestions or links would be much appreciated. Paul
Advertisement
In general, I would do that with an impulse-based system, if you really want to reach such level of detail (friction).
That means, define several constants for each object, like surface structure. When the ball hits the ground, it won''t affect the ground (you can neglect that, I guess *fg*), but it will have an impact on the ball.

So seperating the environment (ground, trees, stationary obstacles etc.) from the rest of your actors (is there any other actor than the ball?) would be a good idea, at least from my point of view.

But it wouldn''t be correct to give you any piece of advice, because that mostly depends on the "surroundings" of your engine, e.g. how collision detection in general is accomplished, if it''s 2D or 3D etc, how many objects are moving etc.

Maybe I could tell you a little more if you could be more specific about what you want



Indeterminatus

--si tacuisses, philosophus mansisses--
Indeterminatus--si tacuisses, philosophus mansisses--
Theres just going to be the the ball and the ground, its more about the physics than making it look good. Its all in 3D, am using a ray test for collision detection purposes.
if you''re doing a raycast, that should return the time of collision, and the normal at point of collision.

1) detect earliest collision
2) move the ball to that time of collision
3) bounce the ball off the plane of collision (defined by the normal and the point of collision)
4) shorten the time left in the frame by the time of collision
5) repeat until no collisions are found

to bounce the ball off the collision plane, there are two methods. the easy way and the hard way.

easy : reflect velocity, with fake added friction and restitution
-----------------------------------------------------------------

float restitution = 0.6f;
float friction = 0.1f;

Vector V = Ball.Velocity;
float vn = V * Ncoll;
Vector Vn = Ncoll * vn;
Vector Vt = V - Vn;
Vector W = Vn * (-restitution) + Vt * (1.0f - friction);
Ball.Velocity = W;

hard : generate an impulse along the plane normal, and friciton force, change momentum of particle
-----------------------------------------------------------------------


well.... try the first one first

Everything is better with Metal.

Thanks for that oliii, the only problem with it is that it doesnt take into account the spin of the ball, really need to incorporate this into it to so for example if the ball has a really fast backspin the ball will bounce backwards.

have got the following equation:

J = -vr(e+1)/[1/m1 + 1/m2 + n.(r1 X n)/ I1 + n.(r2 X n)/ I2]

where
J is the impulse in the normal direction
vr is the relative velocity along the line of action
I 1 and 2 are impulses

v1(after) = v1(before) + [J n + (mu J) t] / m1
v2(after) = v2(before) + [-J n + (mu J) t] / m2
w1(after) = w1(before) + {r1 X [J n + (mu J) t]}/Icg
w2(after) = w2(before) + {r2 X [J n + (mu J) t]}/Icg

where t is the unit tangent vector
and I presume Icg is the impulse around the center of gravity

This is for collisions between two objects. Am not sure as how to change this so that it can be used in my situation, if it can at all. Am also not entirely sure how to calculate I1, I2 and Icg. Am not too good at all this rotation stuff.


[edited by - Paul7 on March 20, 2004 9:36:33 AM]
the equation looks correct. So, it gives you the change in linear and angular velocity, which is what you want.

vr is the relative velocity at the contact point. so it''s a combination of the linear velocity, the angular velocity, and the point of collision distance from the centre of mass of teh objects. But I think you''ve got it covered.

unfortunately, for a sphere, the change in angular impulse will be 0, since r x j will be 0.

you have to add friction to the equation, to generate a change in angular momentum. you can model the friciton by taking the magnitude of Jn, multiply it by the coefficient of friction, and direct it against the tangential velocity.

I''ve got a 2D collision demo here, and a 3D demo, if you want to have a look. for the 2D demo, the impulse code is the Contact class.

Everything is better with Metal.

I think friction is already included in it. mu is the coefficient of friction. The equation takes into account the mass and radius of both objects, as the ground is one of the objects what do I do for this??
ah, ok.

For a mobile against a body of infinite mass, replace one of the mass (m1 or m2, depending on which body it is) by 0, or rather, 1 / mass = 0. Same for inertia. the inverse inertia matrix will be a zero matrix. Same for calculating the relative velocity. you can set the linear and angular velocity of the massive object with zero values (that is, if the massive object does not move obviously).

then the equations will become simpler. Or you can use the same equation, and zero some components.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement