# AABB vs SAT – 2D Collision Detection

[Music] Well, there’s a couple of ways to check if

two objects are colliding. But this video will be focusing on the two

most popular for 2D collision. AABB and SAT. Axis-Aligned Bounding Box collision detection

only works with rectangles that are aligned to the X and Y axes. But it’s also very simple. The way to check if two rectangles are colliding

with AABB is by performing four different checks that compare the vertices of the two

rectangles. If all the checks are true, then the two rectangles

are colliding. Collision detection using the Separating Axis

Theorem however, lets you check if two convex shapes are colliding and also allows rotation. But, it’s also a little more complicated. To check collision with SAT, you first need

to find the normals of all the edges on both shapes. Then, for each normal you need to find the

“shadows” that the two shapes cast. If for every normal the shadows overlap, then

the shapes are colliding. Otherwise, they aren’t and the axis that the

shadows don’t overlap on is the separating axis. Now, for concave shapes, all you need to do

is split them up into multiple convex shapes and then perform the same (SAT) checks again. Now let’s say you have a convex shape and

a circle, how do you check if they’re colliding? Well, it’s easier than you think. Since a circle has infinite normals, you can’t

check it like you would with two convex shapes. Instead, you use *this* axis which goes from

the circle’s center to the closest point (vertex) on the polygon. Then you can perform the checks with SAT as

you would normally. But what if you have two circles though? Well, that’s even easier! You just have to check if the distance between

the two circles is less than the sum of their radii. Anyway, that’s the basics of how AABB and

SAT collision work. Hopefully, you learned something or understand

it a little bit better now but, thanks for watching and I’ll see you guys next time. [Music]

what a nerd

But why did you make a new channel

You said sat. I thought “oh deng we gettin into real high school territory here”

Really nice video, reminds me of a 3blue1brown explanation video with the animations and stuff, nice work.

sat sounds annoying. there’s got to be an easier way for rotating squares.