pierznj
- 4
- 0
I have written a computer game which involves 2D asteroids spinning and colliding with one another. Out of some kind of pride or something I wrote my own physics engine to handle the collisions, even though I never studied physics. (Please excuse therefore any incorrect terminology). Nevertheless, it works well overall and I have a good grasp on what's going as a result of having to having to think everything through from first principles. But I do have one problem.
When two objects collide I calculate a linear and an angular deflection vector for each object based on their momentum, spin and mass. The method looks something like this:
1 Project the angular and linear momenta of both objects onto the line perpendicular to the surface at the point of collision.
2 Add these momenta all together into a single collision momentum. As the objects are perfectly elastic, I multiply by two, so that when the deflection is subtracted from the current momentum, the objects will bounce.
3 Divide this up between the two objects to provide an overall deflection for each object.
4 Project this momentum vector onto the line to the center of the object from the collision point to get a linear deflection.
5 The remainder of the momentum is angular momentum and gets translated into spin (project the deflection vector onto a tangent to the path traced by the collision point as it rotates- I don't have the terminology happening here at all!).
The problem is how much spin to impart for a given amount of angular deflection. At the moment I simply add the angular deflection vector to the rotating speed of the surface at the point of the collision. So if the linear deflection vector and the angular deflection vector both have a length of 3, I subtract 3 units of speed from the object's linear momentum, and I work out the spin change required such that the surface will rotate 3 units slower (or faster) at the point of contact.
But this seems wrong, because spinning an object's surface with a speed of 3 would surely require less energy than accelerating it 3 units of speed linearly, since the mass nearer the center will be moving more slowly than 3. My approximation works OK for fairly regular asteroids, but I'm concerned about more irregular ones. And given the weird shapes of some of my asteroids (they are actual asteroid photographs), I have no idea how to go about calculating the correct deflection.
Any help appreciated greatly - I hope you can understand my lay explanation.
When two objects collide I calculate a linear and an angular deflection vector for each object based on their momentum, spin and mass. The method looks something like this:
1 Project the angular and linear momenta of both objects onto the line perpendicular to the surface at the point of collision.
2 Add these momenta all together into a single collision momentum. As the objects are perfectly elastic, I multiply by two, so that when the deflection is subtracted from the current momentum, the objects will bounce.
3 Divide this up between the two objects to provide an overall deflection for each object.
4 Project this momentum vector onto the line to the center of the object from the collision point to get a linear deflection.
5 The remainder of the momentum is angular momentum and gets translated into spin (project the deflection vector onto a tangent to the path traced by the collision point as it rotates- I don't have the terminology happening here at all!).
The problem is how much spin to impart for a given amount of angular deflection. At the moment I simply add the angular deflection vector to the rotating speed of the surface at the point of the collision. So if the linear deflection vector and the angular deflection vector both have a length of 3, I subtract 3 units of speed from the object's linear momentum, and I work out the spin change required such that the surface will rotate 3 units slower (or faster) at the point of contact.
But this seems wrong, because spinning an object's surface with a speed of 3 would surely require less energy than accelerating it 3 units of speed linearly, since the mass nearer the center will be moving more slowly than 3. My approximation works OK for fairly regular asteroids, but I'm concerned about more irregular ones. And given the weird shapes of some of my asteroids (they are actual asteroid photographs), I have no idea how to go about calculating the correct deflection.
Any help appreciated greatly - I hope you can understand my lay explanation.