Questions tagged [separating-axis-theorem]

A geometry theorem used to determine if two polygonal shapes intersect.

The separating axis theorem(SAT) says that:

Two convex objects do not overlap if there exists a line (called axis) onto which the two objects' projections do not overlap.

SAT suggests an algorithm for testing whether two convex solids intersect or not.

Regardless of dimensionality, the separating axis is always a line. For example, in 3D, the space is separated by planes, but the separating axis is perpendicular to the separating plane.

The separating axis theorem can be applied for fast collision detection between polygon meshes. Each face's normal or other feature directions is used as a separating axis, as well as the cross products. Note that this yields possible separating axes, not separating lines/planes.

If the cross products were not used, certain edge-on-edge non-colliding cases would be treated as colliding. For increased efficiency, parallel axes may be calculated as a single axis.

Source: Wikipedia

32 questions
148
votes
20 answers

Algorithm to detect intersection of two rectangles?

I'm looking for an algorithm to detect if two rectangles intersect (one at an arbitrary angle, the other with only vertical/horizontal lines). Testing if a corner of one is in the other ALMOST works. It fails if the rectangles form a cross-like…
user20493
  • 5,704
  • 7
  • 34
  • 31
10
votes
1 answer

Objective-C check if subviews of rotated UIViews intersect?

I don't know where to start with this one. Obviously CGRectIntersectsRect will not work in this case, and you'll see why. I have a subclass of UIView that has a UIImageView inside it that is placed in the exact center of the UIView: I then rotate…
Liftoff
  • 24,717
  • 13
  • 66
  • 119
9
votes
4 answers

SAT Polygon Circle Collision - resolve the intersection in the direction of velocity & determine side of collision

Summary This question is in JavaScript, but an answer in any language, pseudo-code, or just the maths would be great! I have been trying to implement the Separating-Axis-Theorem to accomplish the following: Detecting an intersection between a…
5
votes
1 answer

Separating axis theorem: rotation around center of mass

The problem is in Polygon::FindAxisLeastPenetration: double Polygon::FindAxisLeastPenetration(unsigned int *faceIndex, const Polygon &polygonA, const Polygon &polygonB) const { double bestDistance = -std::numeric_limits::infinity(); …
ivknv
  • 305
  • 1
  • 4
  • 14
4
votes
1 answer

Point of intersection between Oriented Boxes (or OBB)

I am trying to write a Rigid body simulator, and during simulation, I am not only interested in finding whether two objects collide or not, but also the point as well as normal of collision. I have found lots of resources which actually says whether…
4
votes
1 answer

Separation Axis Theorem MVT along only one axis

I am having trouble calculating 3D penetration vector along one axis. I already implemented SAT and it works. I want to calculate how much i need to offset first box from other so it will always sit on top of other. Kind of doing simple box cast…
BlackCat
  • 329
  • 5
  • 17
4
votes
1 answer

Determine if crop rect is entirely contained within rotated UIView

Premise: I'm building a cropping tool that handles two-finger arbitrary rotation of an image as well as arbitrary cropping. Sometimes the image ends up rotated in a way that empty space is inserted to fill a gap between the rotated image and the…
brandonscript
  • 68,675
  • 32
  • 163
  • 220
3
votes
2 answers

Separating Axis Theorem function fails when met with acute angles

This is a little library I was making for the LOVE2D engine in Lua, which uses separating axis theorem to solve collisions. I was so happy when I got my SAT program to work, and started testing it with a multitude of polygons. It works in most…
3
votes
1 answer

Calculating the resultant velocity vector after a 2D collision

Currently I have a mini physics game which uses Separating Axis Theorem for collision detecting and response, however I came to a standstill when I discovered that there wasn't much documentation on what happens to an object's velocity after it…
2
votes
1 answer

Finding the MTV (Minimal Translation Vector) using Separating Axis Theorem

So I've been trying to get collision detection and response working in my game project using the Separating Axis Theorem. I've managed to detect the collision, but for the life of me I cannot manage to figure out how to respond to it. I'm attempting…
Gyo
  • 57
  • 1
  • 5
2
votes
1 answer

SAT Minimum Translation Vector isn't correct

Is SAT's Minimum Translation Vector always correct and precise in all instances? I calculate it by iterating over all the possible axes and check for overlap on each then keep tracking of which axis has the shortest overlap and using that as the…
1
vote
1 answer

Triangle to AABB collision code not working

I have been tweaking and reworking my code to test an AABB against a triangle and I am unsure what I am doing wrong. I am using separating axis theorem as I believe this is the best and only way used to detect collisions between an AABB and Triangle…
1
vote
1 answer

How get a collision point with SAT

I have implemented SAT collision detection system in 2D , but I don't get how get a collision impact point. For the moment I obtain the mtv and the separating axis, so I can resolve the collision but not apply correct forces on it, because impact…
1
vote
0 answers

How to find minimum translation vector of rotated squares?

I've made a collision detection algorithm that can detect if rotated squares are colliding. I am struggling to understand what I should do to resolve these collisions. I think the first step is to calculate a minimum translation vector (MTV) that…
Toxic Tom
  • 174
  • 12
1
vote
0 answers

Can I simplify this implementation of the separating axis theorem?

I have a working convex 2d polygon vs convex 2d polygon collision test based on the separating axes theorem (SAT). My question is: Is it possibly to implement this algorithm without correcting the direction of the MTV in some form? (by paying…
A.B.
  • 15,364
  • 3
  • 61
  • 64
1
2 3