1 | initial version |
I think you want to find the largest inscribed rectangle in a non-convex polygon (there are algorithms that can to that), but since you have the coordinates of your corner points you may use them in a simpler approach to define your rectangle. Please note that your rectangle will be based on two left corners of your left image and two right corners of your right image. The top-left vertical coordinate of your desired rectangle will be the largest of the vertical coordinates of your top corners. The top-left horizontal coordinate will be the largest of your horizontal coordinates of your left corners. If you follow this line of thinking you will find your rectangle.