Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intersection of a 2D segment with a rectangle

I using C# and XNA. I need an algorithm in any language to obtain the border intersection point(s) of a rectangle with a 2d segment.

I've been looking for an answer for my question for over 3 hours already and couldn't find a solution that works.

Can anyone help me please?

Thanks a lot.

like image 690
Fernando Wieliczko Avatar asked Oct 11 '22 01:10

Fernando Wieliczko


1 Answers

You can find an example for a line segment intersection with an aabb box here.

Or the same question as your question here

like image 151
Fox32 Avatar answered Oct 20 '22 00:10

Fox32