collision-detection

Show bounding box of UIImageView in UIView

I have written a class extending UIImageView in order to allow me dynamically generate bricks on screen. The brick is a 20x10 PNG. Here is my codes: - (id) initBrick:(NSInteger *)str x:(float)ptX y:(float)ptY { int brickIndex = arc4random() % 10 + 1; NSString *filename = [NSString stringWithFormat:@"brick%d.png", brickIndex]; UIImage ...

Collision Detection in iPhone SDK: Inaccurate CGRectIntersectsRect

When there are two objects going to collide, I check them with CGRectIntersectsRect. However, before it returns me with YES (they collide), they are already overlapped. Is there any other way to detect and resolve collision? My workaround is to compare their Y axis and move the object far apart from each other, once they are detected co...

Circle-Rectangle collision detection finished exampe

Hi I need a algorithm for detecting if a circle has hit a square, and I saw this post: Circle-Rectangle collision detection (intersection) It looks like I should go for ShreevatsaR's answer, but I am a math fool, and I have no idea how to finish the algorithm. Could anyone find the time to make a complete example for me please, I have ...

Can anyone help with the collision detect for my platformer? (Actionscript 3.0)

Im currently working on making a flash platformer engine...but my collision detect needs some serious help. Whenever my character 'jumps', and lands on the collision object, he goes about halfway through it for a split second, then goes back to the top (where I want him to be). If I continue to jump multiple times, the shadow of him, if ...

Broad-phase collision detection methods?

I'm building a 2D physics engine and I want to add broad-phase collision detection, though I only know of 2 or 3 types: Check everything against everything else (O(n^2) complexity) Sweep and Prune (sort and sweep) something about Binary Space Partition (not sure how to do this) But surely there's more options right? what are they? A...

Polygon Intersection fails, collision "size" too big

OK, so I'm trying to make a simple asteroids clone. Everything works fine, except for the collision detection. I have two different versions, the first one uses java.awt.geom.Area: // polygon is a java.awt.Polygon and p is the other one final Area intersect = new Area(); intersect.add(new Area(polygon)); intersect.intersect(new Area(p....

circle-circle collision

I am going to develop a 2-d ball game where two balls (circles) collide. Now I have the problem with determining the colliding point (in fact, determining whether they are colliding in x-axis/y-axis). I have an idea that when the difference between the y coordinate of 2 balls is greater than the x coordinate difference then they collid...

Bounding ellipse

I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn't have to be axis aligned. This is working in java (euch) using the AWT shapes, so I can use all the tools shape provides for checking containment/intersection of objects....

Collision detection

I am doing a project where there is a room filled with objects with different shapes. I am drawing the room in paint, being the picture all white and painting all the walls/obstacles red. I am drawing each movable object in a different file, also using paint. Now, I load both the map of the room and the objects as matrix of 1's and 0'...

What's a good, simple, 2D rectangles-only collision detection algorithm?

I'm designing a collision detection game tutorial for young adults, so I want this to be as simple as possible to make it easier to explain. The requirements are very simple. The world is 2D and contains only rectangles (of arbitrary sizes). BSP and even quadtrees seems like it would be overkill (again, the emphasis is on simplicity) bu...

avoiding geocode range collisions

I am in the process of extracting location entities ('Madison Square Garden', 'San Diego Zoo', etc.) from a large table of non-uniform location. I'm trying to avoid multiple entities in my new table. I don't have reliable street addresses, but am trying to extract addresses within a local range. I am doing this by counting and matchin...

How can I know if two rectangles collide in Silverlight 3?

I have program where you cannot place rectangles over each others, so how can I check if rectangles collide? Is there some kind of function for this or do I have to make my own? ...

Why do I get an error when I try to access a public function of a class? (Actionscript 3)

Hi, I'm currently building the damage mechanic for my game. Two classes handle this, the 'hurt' class, and the 'collision' class. The hurt class passes an instance of itself to the 'hurtCollision' method of the collision class, so that the collision class can detect a collision between the player and that instance of hurt (which is a di...

OO design and mirrored/duplicated methods

Hi everyone! I'm having an issue in OO design where I end up with duplicate code in 2 different classes. Here's what's going on: In this example, I want to detect collision between game objects. I have a base CollisionObject that holds common methods (such as checkForCollisionWith) and CollisionObjectBox, CollisionObjectCircle, Collis...

Collision Handling Between Circle and Line Segments

Hello, I'm implementing a small game and am having trouble getting the physics working properly. In this game, there is one ball (a circle which moves from frame to frame, and may change radius) and several walls (line segments which also change and move from frame to frame). I can detect collisions properly, and making the ball bounce ...

Simple Problem - Velocity and Collisions

Okay I'm working on a Space sim and as most space sims I need to work out where the opponents ship will be (the 3d position) when my bullet reaches it. How do I calculate this from the velocity that bullets travel at and the velocity of the opponents ship? ...

Triangle - Triangle Intersection Test.

I'd like to know if there is out there some tutorial or guide to understand and implement a Triangle-Triangle intersection test in a 3D Environment. (i don't need to know precise where the intersection happened, but only that an intersection has occurred) I was going to implement it following a theoric pdf, but i'm pretty stuck at the ...

How to pre-calculate the trajectories in a billiard (pool) game?

Hi; Most collision detection algorithm in billiard uses a naive approch, where the balls' positions are incremented and then checked for collisions. This method dosen't work well when the speed are really high because we might "skip" collisions. I have been searching for a way to pre-calculate the trajectories of the balls in a billiar...

Collision Detection between Accelerating Spheres

I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well, however, one thing that I need help with is the math of the collision detection algorithim. The iterative simulation of movement that I am using is basically as ...

How does 3D collision / object detection work?

I'v always wondered this. In a game like GTA where there are 10s of thousands of objects, how does the game know as soon as you're on a health pack? There can't possibly be an event listener for each object? Iterating isn't good either? I'm just wondering how it's actually done. ...