Unless you were also using circles my code would probably be of little help to you.
I use the distance formula to find the distance between centers, then check to see if that's less than the radii of the circles combined. If so 'lengthly algo here'. Also, using a a^2+b^2=c^2 deviation, I calculate the points where the centers of the two collosioning objects should be. The hope is of course they don't overlap and using this method has given me decent results.
The bouncing is determained by the x,y (again a^2+b^2=c^2, find C from the movements). That is used to conserve momentum.
There are also friction and gravity forces.
The method I use for determaining the resultant vector post collide isn't very accurate, but for all intents of this program, it suffices. The objects trade vectors. There is no glancing programming yet. I am, however; making advances towards such.
maybe I don't get your point, but I see bubbles that overlap each other (not only the shaded part, but also the solid blue part up to the white light-reflection).
ust look at a bubble in the middle of a big number of others.
I think at some times another bubble can overrun the investigated.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
The first is far better at conservation of momentum, while the second yields more precise resultant vectors. But the magnitude of such results are not at all accurate as the first's.
Two balls colliding at high speed, overlaps each other if the collision detection is performed after the balls have moved. This also results in incorrect distribution of momentum. I had to solve this problem once earlier: http://www.vbforums.com/showthread.p...threadid=75004
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Originally posted by kedaman Two balls colliding at high speed, overlaps each other if the collision detection is performed after the balls have moved. This also results in incorrect distribution of momentum. I had to solve this problem once earlier: http://www.vbforums.com/showthread.p...threadid=75004
I modify the code to check such things.
The problem is there really is no time varible.
I could however move both particles to their destinations then if the dist > radii then step back. The problem is the stepping back just adds further calculation.
You calculate the time at which the collision occurs relative to the time unit at which you move the balls one step in your loop, from the formula of distance per velocity t=x/v, in this case |X+Vt|=r1+r2, X and V are the position and velocity vectors of which one of the balls moves relative to the other.
Last edited by kedaman; Dec 4th, 2002 at 08:56 PM.
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Originally posted by kedaman You calculate the time at which the collision occurs relative to the time unit at which you move the balls one step in your loop, from the formula of distance per velocity t=x/v, in this case |X+Vt|=r1+r2, X and V are the position and velocity vectors of which one of the balls moves relative to the other.
There's the source code *looks up a few posts*.
Feel free to add your additions then post an updated version.
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
I'm using it on a Win2000 system, and whren clicking on FullScreen a second window for fullscreeen is created, but the original one remains there. The second (full screen) one has just the window title and a black background.
Is that correct?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!