Re: Bouncing circles, simple



cr88192 wrote:
"Mike Austin" <no@xxxxxxxx> wrote in message
<snip>
I don't know why you're using e or what restitution is supposed to do. Here's my revised pseudo-code, but I'm not sure it conserves momentum - "object_a velocity length + object_b velocity length" should be equal before and after the collision, correct?

e is mostly just what I used before (originally I think it came from one of the papers I read). however, the notion was not new to me, just, previously, I had not bothered to come up with a good name for it anyways (it was stuck in one of my general purpose 'f' or 'g' variables).


generally, it refers to how much of a "bounce force" to add. otherwise, if all is working well, the objects should not bounce (inelastic collisions).
I am, however, not sure on whether or not the laws of conservation still hold (whenever there is a collision, a little fudging is made to the forces). reality works a little different on this front, and typically physical realism was put at a lower priority than "visual realism".


relative_position = object_a.position - object_b.position
incident_angle = atan2( relative_position.y, relative_position.x )
velocity_angle = atan2( object_a.velocity.y, object_a.velocity.x )
magnitude := object_a.velocity length * cos( incident_angle - velocity_angle )


object_a.velocity -= vector( cos( incident_angle ) * magnitude,
                            sin( incident_angle ) * magnitude )
object_b.velocity += vector( cos( incident_angle ) * magnitude,
                            sin( incident_angle ) * magnitude )

[calc object_b]


yeah, it might work. if one does not need mass or other features, this could be ok.

The problem still remains that it does not conserve momentum. At an incident angle of 45d, a ball moving at speed 1 that collided with a stationary ball will result in each ball having the speed .7071 (cos 45). At 45d, ball1 should transfre half it's momentum, correct?


still, worth noting:
though subtle, I still view "impulses" as an important feature.
instead of applying forces to velocity directly, they accumulate them and add them at the end of the frame.


something like:
object_a.impulse -= vector( cos( incident_angle ) * magnitude,
                             sin( incident_angle ) * magnitude )
object_b.impulse += vector( cos( incident_angle ) * magnitude,
                             sin( incident_angle ) * magnitude )

and after all the physics are done:
object.velocity += object.impulse
object.impulse = vector(0, 0)

the effects of this are related to multiple contacts.

in the multiple contact case, often, one collision will prevent correctly handling another, and so forth (a simple example of this would be, in the case of multiple contacts, some contacts having little effect on an objects movement, so during that time, eg, an object will head right through another or other weird effects).

otherwise, it is not that expensive to add them.

I get it, thanks. .



Relevant Pages

  • Re: Are physics cranks employed?
    ... There is no velocity for a round trip, ... Still zero, you stupid cunt. ... circuit at a speed of 299,792,458 m/s and crosses the finish line at ... speed is the magnitude of velocity and the velocity is zero. ...
    (sci.physics)
  • Re: Is ther in truth, no mass???
    ... A skateboarder is moving at 7.83 m/s along a horizontal section of a track that is slanted upward by 47.1 ° above the horizontal at its end, which is 0.768 m above the ground. ... Assume that the only force acting on him during the collision is that due to the ground. ... The swimmer then runs off the raft horizontally with a velocity of +5.87 m/s relative to the shore. ... Puck A has a mass of 0.0210 kg and is moving along the x axis with a velocity of +6.45 m/s. ...
    (sci.physics)
  • Re: Mechanics: problem of falling stick by I. E. Irodov
    ... then its velocity is not altered. ... here's the geometry just before the collision: ... So the collision can be treated for each mass ... by its total momentum and the angular momentum about the center of mass. ...
    (sci.physics.research)
  • Re: Sliding motion with multiple constraints
    ... or using position and collision detection (move until you ... When your dude hits a wall in GTA, ... Moving the player so he is not in the wall gives the appearance ... of altering the velocity. ...
    (comp.games.development.programming.algorithms)
  • Re: Counter-Intuitive Collision Frequency Result
    ... I want to derive the expression for the collision frequency of a single gas molecule (which I'll call a "test particle") if its velocity is v. ... You have a velocity distribution $f$. ...
    (sci.physics)