#112833 - sirpoonga - Wed Dec 20, 2006 7:13 pm
I've been trying to find resources on collision detection and response for circles and boxes. Doing a circle and a plane is pretty easy. But a circle and a point I am having trouble finding info on.
What I am finding involves floating point math. I know I will need to convert that to fixed point so that is another task I have to look up after figuring this out. Right now I don't care how slow it runs, I just want to get the concepts down.
I am working on a labyrinth game for the DS and the DS Motion detector.
http://img.photobucket.com/albums/v472/SirPoonga/gamedev/maze2.jpg
I would like the physics to be realistic, but will take shortcuts where necessary.
I do plan on implementing friction and elasticity (can choose from different types of balls - rubber bouncy ball, metal bearing, etc...).
Since the walls are at horizontal and verticle angles that simplifies things. Testing if the ball will collide with a wall edge is easy. Actually, detecting if it will collide with a corner is easy.
What I am finding trouble with is determining the response, the new velocity vector after hitting a corner. And edge is easy, you just flop sign bit for the one axis. Then take that vector and multiply by elasticity.
From what I understand about circles and corners you need to calculate the exact moment the circle collided. And then there is some calculations with the normalized vector that is created from the corner point to the circle center. That's about all I have gathered, I've only found generalizations and nothing specific.
Some of my conclusions so far:
The vector direction created between the corner and the circle center is the direction of the force the corner is going to apply. The amount of force, as Newton put it, would be the same amount as what the ball puts int he opposite direction, right? So the question now is how do I determine how much force was applied in that direction? I suppose mass would make a difference here. To simplify things maybe I will make mass a constant of 1.
High school physics is vaguely coming back...
What I am finding involves floating point math. I know I will need to convert that to fixed point so that is another task I have to look up after figuring this out. Right now I don't care how slow it runs, I just want to get the concepts down.
I am working on a labyrinth game for the DS and the DS Motion detector.
http://img.photobucket.com/albums/v472/SirPoonga/gamedev/maze2.jpg
I would like the physics to be realistic, but will take shortcuts where necessary.
I do plan on implementing friction and elasticity (can choose from different types of balls - rubber bouncy ball, metal bearing, etc...).
Since the walls are at horizontal and verticle angles that simplifies things. Testing if the ball will collide with a wall edge is easy. Actually, detecting if it will collide with a corner is easy.
What I am finding trouble with is determining the response, the new velocity vector after hitting a corner. And edge is easy, you just flop sign bit for the one axis. Then take that vector and multiply by elasticity.
From what I understand about circles and corners you need to calculate the exact moment the circle collided. And then there is some calculations with the normalized vector that is created from the corner point to the circle center. That's about all I have gathered, I've only found generalizations and nothing specific.
Some of my conclusions so far:
The vector direction created between the corner and the circle center is the direction of the force the corner is going to apply. The amount of force, as Newton put it, would be the same amount as what the ball puts int he opposite direction, right? So the question now is how do I determine how much force was applied in that direction? I suppose mass would make a difference here. To simplify things maybe I will make mass a constant of 1.
High school physics is vaguely coming back...