collision-detection

What's the best way to implement one-dimensional collision detection?

I'm writing a piece of simulation software, and need an efficient way to test for collisions along a line. The simulation is of a train crossing several switches on a track. When a wheel comes within N inches of the switch, the switch turns on, then turns off when the wheel leaves. Since all wheels are the same size, and all switches ar...

Opinions on platform game actor/background collision resolving

Imagine the following scenario: I have a level whose physical structure is built up from a collection of bounding rectangles, combined with prerendered bitmap backgrounds. My actors, including the player character, all have their own bounding rectangle. If an actor manages to get stuck inside a level block, partially or otherwise, it'll ...

What is an efficient way to find a non-colliding rectangle nearest to a location

For a 2D game I am working on, I am using y axis sorting in a simple rectangle-based collision detection. This is working fine, and now I want to find the nearest empty rectangle at a given location with a given size, efficiently. How can I do this? Is there an algorithm? I could think of a simple brute force grid test (with each grid t...

Collision Points in GJK

Is there a way to modify a Gilbert-Johnson-Keerthi Algorithm so it finds points of the collision between two bodies instead of a true/false result ? From what I've understood the received distance value could be used to find these points. I searched the web but didn't find any hints. ...

Collision detection 2D between rectangles

Hello. I am writting a collision detection engine for my game and I have some problems. Indeed, since I have several fixed rectangle and one moving (the player), I need to know which side of the fixed one was collided at first by the player, to replace him correctly. The fixed rectangle are NOT in a grid so they can be placed anywhere...

Collision detecting custom sketched shape, represented as list of points

I have a set of points, drawn by the user. They will be drawing around some objects. I need to somehow turn this set of points into a shape, so I can find the area to detect collisions. An image will clarify: . The best idea I have had so far involves iterating over every pixel determining if it is 'inside' or 'outside' the shape, b...

Polygon to Polygon Collision Detection Issue

Hey guys, I have been having a few issues implementing my narrow phase collision detection. Broadphase is working perfectly. I have a group of polygons, that have a stl::vector array of points for their vertices in clockwise order. Every cycle, I check to see whether they're colliding. I have borrowed the following Point in Polygon ...

check for overlap

Hi everyone, I'm using FullCalendar and just wanted to know how I can check for overlap date and time. I have a start and an end date but dont know how I can accomplish this. Any suggestion/ideas/inputs would be helpful. Regards, Yuepheng ...

Collision detection in TouchMoved Event

I know this is somewhat a noob question but anyways im having hard time figuring it out. Im trying to cancel out the touchmove event on an UIImage when it colide with other UIImage. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPosition = [touch locationInView:sel...

JavaScript TagCloud Avoid Overlapping

I’m creating a tag cloud using JavaScript. It takes an unordered list of 'tags', and then distributes them randomly from the centermost-point of the div (Gaussian distribution). The trouble I'm having is finding an efficient metric to determine if any of my tags are overlapping. Ultimately I came up with 2 approaches: (1) position eac...

Help with Triangle collision detection in Obj-C

I haven't taken any advanced math courses or anything (I'm still in high school) and I just don't really understand all the triangle collision systems online. I have two triangular objects in a 2D space. How should I write Obj-C code so that a collision/intersection between the two can be detected? I'm stumped. ...

Collision Detection in OpenGL ES on the iPhone

I seem to be having a strange issue with a 2D game I'm working on. In order to determine if my playable character sprite lands on a platform I first do an if statement checking CGRectIntersectsRect and once I've determined that the player sprite and platform sprite have intersected, I then check to make sure that the center point (plus h...

How can I detect a collision between a moving object and an immobile one?

Hello, First of all, my question isn't really specific to C# or XNA, but my code examples will use these. Also, sorry for the title, I didn't know how to express my question properly. I am currently trying to make a Pong clone and I've run into a problem with collision-detection. Each object basicly has a specific Velocity(which is a...

[javascript] Click on given element in canvas.

Is there any trick to determine if user clicks on given element rendered in canvas? For example I'm displaying rhombus from .png file with transparent background and i want to know if user click inside or outside that figure (like mouse-element collision). ...

3d race game collision detection

Can somebody explain how the collision detection works for race tracks in games like need for speed or wipeout? ...

Sphere - sphere collision detection -> reaction

Hi guys, I need to make an algorithm that detects when two spheres collide, and, the direction that wich one will take an instant after the collision. Let say, Imagine like when you open your table in a pool match, all the balls are colliding one to another "randomly". So, before starting to write the code myself, I was thinking if th...

how to make general collision with images in for loop

collison but its only working for 1 image - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint p = [touch locationInView:self.view]; if (CGRectContainsPoint(CGRectMake(myImage1.frame.origin.x, myImage1.frame.origin.y, myImage1.frame.size.width, myImage1.frame...

Good 2D Collision Response References

Hey, I'm currently looking for various methods of implementing collision response in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner frien...

Collision detection using mulitple subviews within a moving view.

I am working on a game in OBJ C that has a ball view and a stage view. The stage view has 4 subviews. All views are UIImageViews. I have a method for collision detection that is working. I would like to expand it to more than 4 subviews without simply creating more lines of code. Looking at the code below, is there a way to simplify this...

Virtual joystick problems.

Hi, So, I am trying to recreate one of those "virtual joysticks" on some of those iPhone games. And basically, heres the problem I can make sure that the user is touching the circle (that is the "virtual joystick") and I can also move the thing around (or at least was able to move it around because since then I have messed around with i...