Rotated 2d Rectangle Intersection Detection

I have two rectangles, they are placed arbitrarily, and I have the rectangles of all four corner points, for example,

struct Rect
{
 NSPoint topLeft; 
 NSPoint topRight; 
 NSPoint bottomLeft; 
 NSPoint bottomRight; 
}

I want to check if 2 rectangles intersect. I am looking for a method similar to NSIntersectsRect. But NSIntersectsRectit will not take into account the rotation of the rectangle. Points in the structure are points obtained after rotation.

Sample code in Objecitve-C, C ++ or C would be a big help.

+2
source share

Source: https://habr.com/ru/post/1759832/


All Articles