Skip to content

Using Separating Axis Theorem to detect if 2 objects are intersecting

Notifications You must be signed in to change notification settings

TheBigKahuna353/Separating-Axis-Theorem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Separating-Axis-Theorem

Using Separating Axis Theorem to detect if 2 objects are intersecting in pygame

So, using the logic of Separating Axis Theorem that if you cant draw a line in between 2 squares then they are overlapping and colliding. I made something close, its not perfect but its close, I also haven't accounted for rotation of squares but if you find a way to find the vertices/corners of the square, then this could easily work. The way i did it was that i turned the squares into lines and drew a line directly in the middle of the squares and at the normal of the line in between the squares, its a bit confusing but it makes sense once you see it. I then used line intersecting maths to find if they intersect.

doing rotating squares: added rotation variable in square class, i used this answer to find the corners of the square, then once i have the corners, used the line intersetion.

About

Using Separating Axis Theorem to detect if 2 objects are intersecting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages