Given two squares on a two-dimensional Cartesian plane, find a line that divides both squares into two equal halves. The line should pass through both squares such that each is split into two regions of equal area.
Input: a = Square(left=0, top=0, size=2), b = Square(left=2, top=0, size=2)
Output: Line passing through (1.0, 1.0) and (3.0, 1.0)
Explanation: The centers are (1,1) and (3,1). The line connecting these centers (y = 1) bisects both squares.
Example 2
1
2
3
Input: a = Square(left=0, top=0, size=2), b = Square(left=0, top=0, size=2)
Output: Any line through (1.0, 1.0) (centers coincide)
Explanation: Both squares have the same center (1,1). Any line through this center divides both squares equally; the implementation may return the center twice.
The only way to guarantee that a line divides both squares into two equal halves is for the line to pass through the center of each square. Any line passing through both centers will split both squares into two regions of equal area.
The line connecting these two centers will cut both squares in half.
If the centers coincide, any line through the center will work.
Given the coordinates of the top-left corner and the size of each square, calculate the center for each. Return the line segment connecting the two centers.