1
\$\begingroup\$

I have created a bouncing ball simulator using XNA and I am happy with my use of gravity, acceleration, change of direction and friction/spin.

However, I am now at a stage where I would like to define my ball as being made of a different material, subsequently meaning that the "bounce height" will be different depending on the elasticity of the material.

Ultimately, I will also want differing types of bounce surfaces as well. This will mean that I could have bounces as varied as:

  • Rubber ball on concrete.
  • Ping-pong ball on wood.
  • Concrete ball on mud.
  • Etc., etc.

My question is; How should I alter my bounce height depending on the material(s)?

I have found some information about Young's Modulus of Elasticity but I would be grateful if someone could advise as to how I use this (or another) value as a ratio in my "bounce" calculation.

Thanks in advance and please let me know if you would like to know anything else.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

The bounce is implemented by inverting the Y component of velocity, when the ball collides with the ground.

Ball.Velocity.Y *= -1 * COEFF;

If the COEFF is 1, the ball will have a "perfect" bounce, i.e. no energy will be lost. If COEFF is 0, the ball won't bounce at all. Put a fractional value between 0 and 1 in COEFF to get a realistic bounce.

Now you want to implement two "materials". So you could have two coefficients and calculate COEFF as follows:

COEFF = BALL_COEFF * SURFACE_COEFF

\$\endgroup\$
8
  • \$\begingroup\$ +1 beat me to it plus a fairly good approximation towards how things are commonly done to achieve that effect. \$\endgroup\$
    – teodron
    May 9, 2012 at 11:12
  • \$\begingroup\$ I would expand on this and say that the angle of the bounce leaving is equal to the angle of the ball coming in relative to the tangent of the point of impact. This way, he could have balls bouncing off the walls or off of irregularly shaped objects and have balls bouncing off of other balls as well (though that one would really be a momentum conservation calculation). Inverting the Y velocity only works going up and down, what if he hits a 45 degree slope coming at a 70 degree angle, it would be vastly different result than coming down at a flat surface \$\endgroup\$
    – Azaral
    May 9, 2012 at 11:33
  • \$\begingroup\$ I've got the Y inversion working fine, when angled surfaces and trajectories are involved. The use of a material coefficient seems like a good answer to my question. How would I determine the coefficients to use? Would it just be a case of testing? Or is there something predefined that I can use (maybe linking to the elasticity ratings for example)? \$\endgroup\$
    – Ste
    May 9, 2012 at 11:53
  • \$\begingroup\$ Personally, I would recommend trying out values and finally selecting what "feels right". \$\endgroup\$
    – ApoorvaJ
    May 9, 2012 at 12:17
  • 4
    \$\begingroup\$ And if COEFF is greater than 1 you have Flubber. \$\endgroup\$
    – DampeS8N
    May 9, 2012 at 12:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .