How to implement restitution coefficient into a simple physics engine?
I am writing a simple 2d physics engine that supports circle-circle collision and i can't figure out how to retrofit my collision resolution method to add res开发者_运维问答titution. How is a restitution coefficient property implemented in physics engines?
I don't know much about implementing game physics but I would use the following formulas found on the wikipedia page:
These formulas tell you the velocy of an object after a collision given your constant Cr. This will be easy to place in your application if:
- You are using vectors to represent everything and you understand (and can perform) vector math (first year University knowledge at the least). Since you are making a physics engine I think you probably do.
- You have given mass to all of the objects in your physics world.
If you have done that then you can use those formulas to decay velocity upon collisions. Your collision calculations are separate to that; this deals with the momentum of your objects.
精彩评论