Line vs Box2D AKA Raycasting | Coding a 2D Physics Engine in Java #7

preview_player
Показать описание

In this tutorial, I explain how to check if a line is intersecting with a box. The way that I accomplish this is using a raycasting techinque (you could achieve the same result using variants of clipping algorithms). I extensively explain the mathematics behind this, going over a concrete example of how the raycast works. I explain how we can use the minimum and maximum of an AABB (2D box) to figure out the entry point and exit point of an intersecting line. Then, we implement the method. I also go over how to extend this functionality to check if a line is intersecting with an OBB (2D rotated box).

0:00 Intro
0:32 Math behind line vs box
15:38 Coding line vs box method

---------------------------------------------------------------------

Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)

My Recommended Game Engine Books:

My Recommended Beginning Game Programming Books:

My Recommended Java Books:

Рекомендации по теме
Комментарии
Автор

Your maths are insane Gabe. From today on, I will NOT think I am good at maths 😉🤔🥶

soccypowa
Автор

I'm having problems creating a new Line2D instance inside a static function...

SpireFool
Автор

can you help me? My line in AABB is not working, don't know why. The point in AABB inside of it works well. But the line does not

renatocesar
visit shbcf.ru