anubis2003
17th March 2003 22:41 UTC
3D Collisions...again
I thought that I had a way to do collisions in 3D, but it doesn't seem to work. No conservation of momentum whatsoever. To help explain my code, here's a brief explanation of what I've done:
I figured out the normal x, y, and z components. I split the 3-D collision into 3 two dimensional collisions(xy, xz, yz). Then I added the resulting velocities of these collisions.
The first mistake that I thought that I made was that I was still using the 3-dimensional normal in my two dimensional equations, but when I tried using three normals seperately(for each plane) I still got the same results.
Any help is greatly appreciated. Thanks.
Nic01
17th March 2003 23:51 UTC
The balls are going maaaaad, I tell you....
..Well, only in the first try. The rest of the time, they're goddamned anemic. Heck, I checked off clear every frame and they're not moving a single bit. I have to put them into an effect list, disable it, and reenable it (Jump-starts the balls)
I don't know what you have in the code so far, but I'll just tell you what I believe are needed for 3d collisions :
1. They're spheres, so to detect collisions you only need distance between the two spheres' centerpoint. The distance for collision is R1+R2 where r is the radius, and since you can't get exactly into the amount needed, use below(r1+r2+n) where n is some small number for when collision occurs.
2a. Direction of collision. Dunno :p mathworld.wolfram.com perhaps?
2b. Speed of the balls. Please, conservation of energy! I don't want the balls to go from the speed of a snail into lightspeed, it just doesn't make sense. I think you'll need to use individual variables for speed in x,y, and z direction for correct speeds...
2c. Direction/speed relation. Change in speed in a collision depends of the direction - head on or barely scratching. The direction also depend on speed difference. The more speed from the other ball, the more change in that direction... remember to compensate for the ball's own speed too.
3. Sense of depth. Otherwise it looks weeeerd.
Anyways, you're getting there, but it's currently hard to see if the balls bounced off correctly...
That and you might want to cheat the 3d rotation since they're just spheres. Rotation of the individual spheres aren't exactly necessary for now - You can fake that.
anubis2003
18th March 2003 01:34 UTC
1. Yeah, collision detection is easy. Got that done.
2a. I'm dealing solely with components. Both with velocities, positions, and the normals. Mathworld has nothing on collisions(that I can use).
2b. I think something is messed up with my collision logic(or I made a stupid mistake).
2c. That's what I use the normals for. I can do the 2-D collisions(I've put it up on the forums already).
3. What do you mean? I used the standard 3D-2D conversion. I will be adding a wireframe box that is inclosing the area that they can bounce in, I'm just lazy.
Oh, and my rotation is "faked". I want to include actual rotation in with the collisions, but that is difficult.
Pixelcraft
18th March 2003 03:17 UTC
Yes this is weird, about 20 seconds into the preset, it looked like the balls got into a catfight! Then they "strobed on my screen for a few seconds and disappeared.
And another thing, I was going to cut and paste the preset into the folder, but I accidentaly left clicked on it. Instead of the "open with" box coming up, a notepad came up with a giant load of math in it. I closed out the notepad and clicked on the preset again, and the "open with" box came up like usual. That's never happened before....
anubis2003
18th March 2003 03:43 UTC
The reason they do that is because momentum isn't being conserved(I don't know why) and the velocities are increasing exponentially.
shreyas_potnis
19th March 2003 05:49 UTC
every action has an equal and opposite reaction...
in the absense of any external unbalanced force, when two bodies collide with each other, their total momentum after collosion is equal to their total momentum before collision...
is there any other external unbalanced force present? :)
anubis2003
19th March 2003 12:01 UTC
No. Just a perfectly elastic collision.
shreyas_potnis
20th March 2003 10:31 UTC
i was just joking ;)