#### Archived

This topic is now archived and is closed to further replies.

# Gravity Collision

This topic is 6107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have an object that loses velocity whenever it touches a surface. Gravity is applied to the velocity every frame, so it bounces down to almost nothing, but it never actually stops bouncing because gravity is constant applied to the object making it just sit there bouncing. Is there a mathematical way to stop this or do you just hack it (stop applying gravity when you think it''s on the ground).

##### Share on other sites
maybe you could stop applying gravity when the object is actually touching some surface... this might not be completely realistic, but during the motion it will only miss one frame of gravity when it bounces, and when they are finally stopped it will let them sit.

--- krez (krezisback@aol.com)

##### Share on other sites
There is a physically realistic way to stop your object oscillating very close to the surface...

First a little background to help people better understand what you are modelling.

Let''s use the Earth as an example. If I throw a ball up into the air it falls under the effect of gravitational acceleration until it hits the ground. At that moment, the ground applies an equal and opposite force to the ball. What is happening is that the momentum in the ball is passed to the Earth and the earth passes an equal and opposite amount of momentum to the ball. This conserves the energy in the collision (actually its energy that is imparted rather than momentum, but momentum is a nice way to view the problem). Here I am assuming we have an elastic collision (i.e. no loss of kinetic energy during the collision).

Since the ball now has momentum of equal value and opposite sign, it is propelled upwards at an appropriate velocity. Gravity is still affecting it and it will eventually fall to collide with the ground again. This system (because it is elastic) will continue to oscillate through the same states.

Consider now an inelastic collision with the ground. The ball strikes the ground imparting its momentum to the earth but the earth returns a lesser amount of momentum to the ball. The ball bounces back from the earth but having less kinetic energy it achieves a lower height (lower potential energy which is equal to the kinetic energy the ball had just after it bounced). The next time it strikes the ground it loses some more kinetic energy (through the momentum exchange). Eventually the ball is bouncing so low that it cannot be seen to be moving, although it still is. This is perhaps, the problem you are describing with your model, even though you haven''t necessarily implemented momentum or an energy computation.

In the real world, the loss of energy during an inelastic collision is dependent on the properties of the colliding objects. You could model this in many ways but here are two simple ones: a) lose a fixed percentage of energy with each collision; or b) lose a fixed amount of energy with each collision.

The first is more realistic but doesn''t get around the problem of your simulation stopping bouncing while the second is just unrealistic. The answer then would be to simulate a loss of a fixed percentage of energy with each collision until the amount of remaining energy is below a threshold. This threshold represents the limit at which oscillation is detectable. Once the balls kinetic energy has been reduced below this threshold, set it to zero. Without momentum the ball is in equilibrium and will stay there until acted upon by an external force.

Here are some equations for momentum and energy to help you out if you choose to implement an energy/momentum computation...

p = m*v
where
p: momentum
m: mass of object
v: velocity of object

k = 1/2mv2
where
k: kinetic energy
m: mass
v: velocity

I hope this has helped you to understand the physical reality of collisions within a gravitational field a little better and hence enabled you to see a way out of your problem.

Cheers,

Timkin

##### Share on other sites
Your description is all correct, just have to say this

I made this project once, with a bouncing ball, and tried to simulate the bounce the easiest way possible.
I simply calculated the gravity with the formula:
ga = v0 + t * 1/2 at2
Where ga is the acceleration of gravity
v0 is the momentum
t is the timeinterval
a is the current acceleration
However I simply turned the momentum upon a hit (*-1) and made it lose energy (procentually as you proscribe).
I think that was all..

##### Share on other sites
When an object hits the ground, it gets a bit "squashed". As this effect gets corrected by elasticity, it lifts itself back off the ground. That''s how bouncing works... even for objects which seem rigid - such as marbles.

What''s the best model for energy loss? It''s hard to say. But my advice is to take off a set percentage at each bounce, then subtract a tiny bit extra. That should at least look realistic.

##### Share on other sites
In the real world Beer Hunter's description of a collision is correct, however I was describing idealised rigid body collisions and using those to come up with a simplistic inelastic collision method. I don't see the need to complicate matters by discussing the compression and distension of colliding objects. The Newtonian method I describe above is suitable for most collision simulations and if used with the multiplicative factor I suggested will give a very realistic decay to the bounce height.

Regards,

Timkin

Edited by - Timkin on November 22, 2001 8:29:05 PM

##### Share on other sites
I dont know how detailed and accurate your physics engine needs to be but the easiest way would be to just move the ball out of your movingObjects list and into the staticObjects list when its velocity gets to approximately 0. Then you wont be plagued by needless collisions.

If you need needs are more along the lines of a physics simulation then i''d do what these other guys suggest and model the momentum or energy of the system.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5
Rutin
12

• 12
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632115
• Total Posts
3004197

×