1

This is a follow up to a question I asked previously. But here is the full question:

Consider two convex polygons A and B. Polygon B lies completely inside polygon A. There are two lines with different slopes (both fixed slopes), such that they have one common end point on or inside B and their other end points (would be different) lie on the boundary of A.

How would you find this common end point inside or on polygon B, if your objective is to maximize the sum of lengths of these two lines?

Sharan
  • 23
  • 3

1 Answers1

0

Obviously the first endpoint should be on the boundary of B. If we find the furthest point of A for each point of the boundary of B, we will have the solution immediately. Suppose x lies on or inside A and y lies on the boundary of B and they are the furthest pair. At this moment we can report (x,x+epsilon,y) as our solution. It means that if you start from 'y' and move in 'xy' direction, you can get the furthest point from 'y'. So 'x' also should lie on boundary, of course the boundary of B. Thus, your question got reduced to find the furthest pair that one point on the boundary of A and the other one on B. For the rest, you can do a binary search on each edge of A and B to find what we want. It takes O(n^2 log^2 n). Of course you can run a better algorithm for the final step to get the better running time.

vahidreza
  • 843
  • 1
  • 8
  • 19