Yet Another Collision Detection Question

t3knomanser
Unregistered
 
Post: #1
I've googled, and read through here, but I'm not seeing anything that maps to my particular collision detection problem.

I'm doing a motion-sensor based application on a MacBookPro (and later for PowerBooks, iBooks, et al), based on the old tabletop Labyrinth mazes. You have to tilt the laptop to control the ball. All of that works fine.

I've written some logic that tests to see if the ball crosses into a rectangle that represents a wall, that works fine too. The problem is, I need to figure out which direction the ball was crossing, and stop the ball so it's like it hit a real wall. The way I'm doing this right now is to:

Check the last location of the ball and the current location of the ball against the bounds of the rectangle- based on where it crosses, move the ball out to coordinates that place it against the wall.

That works, so long as the ball hits squarely on one of the sides of the square. When it hits a CORNER, a skilled and careful player can make the ball pass through the wall.

So, I can detect collisions using a simple bounds test, and then, based on the previous and current locations of the ball, I do an a posteriori test to see where the ball broke through, and then reposition the ball against the outermost edge of the box in that direction.

The problem with my current methodology is that the ball can pass through the corners of the box. How do I resolve this?
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #2
You need to also have a circle/point collision function which you apply to the corners in addition to testing edges. If you make a circle/circle collision function then you can add circles as well as rectangles to your maze (they can also become "holes" that you have to maneuver around if you want!) I mention this because circle/circle can be used as circle/point if once circle has a radius 0.

Check out:
http://www.geometrictools.com/Intersection.html

hth,
Codemattic
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Optimize the collision detection alaslipknot 1 2,779 May 12, 2013 08:02 PM
Last Post: SethWillits
  Collision detection tutorial ThemsAllTook 7 22,813 Nov 5, 2011 05:20 PM
Last Post: SethWillits
  Help with Collision Detection..(i'm almost there) carmine 1 4,685 Jun 29, 2011 12:33 PM
Last Post: ThemsAllTook
  Time Delta, collision detection mk12 19 15,627 Sep 8, 2010 06:40 PM
Last Post: AnotherJake
  Collision detection for pinball game johncmurphy 0 4,796 Sep 6, 2009 02:46 PM
Last Post: johncmurphy