Friday, December 29, 2017

xna - Ball Physics : Bounce height altered by elasticity of ball and bounce surface



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.



Answer



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


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...