I have two segments one above the other and they do not cross, and a point$\ p $ between the two.
I must draw a line that connects the 2 segments and the point, each of the line's ends is at a ratio of the distance between the two points of each segment.
That ratio must be the same for both top and bot segment and starts from the left to right.
$\ tl $ = top left corner
$\ tr $ = top right corner
$\ bl $ = bottom left corner
$\ br $ = bottom right corner
Here is how I tried to solve the problem:
x = amount of distance between either points of a segment, takes values between 0 and 1
top = the line's top point that connects with the top segment
bot = the line's bot point that connects with the bot segment
top = $\ (1 - x) tl + x tr $
bot = $\ (1 - x) bl + x br $
top_dist = distance between$\ p$ and$\ top$
bot_dist = distance between$\ p$ and$\ bot$
sum_dist = distance$\ bot$ and$\ bot$
top_dist = $\sqrt{(p_u - top_u)^2 + (p_v - top_v)^2} $
bot_dist = $\sqrt{(p_u - bot_u)^2 + (p_v - bot_v)^2} $
sum_dist = $\sqrt{(bot_u - top_u)^2 + (bot_u - top_v)^2} $
Ensure $\ top$, $\ bot$ and $\ p$ are collinear
top_dist + bot_dist - sum_dist = 0
$$\sqrt{[p_u - ((1 - x) tl_u + x tr_u)] ^2 + [p_v - ((1 - x) tl_v + x tr_v)] ^2} + \sqrt{[p_u - ((1 - x) bl_u + x br_u)] ^2 + [p_v - ((1 - x) bl_v + x br_v)] ^2} - \sqrt{[((1 - x) bl_u + x br_u) - ((1 - x) tl_u + x tr_u)] ^2 + [((1 - x) bl_v + x br_v) - ((1 - x) tl_v + x tr_v)] ^2} = 0 $$ Solving parametrically I get to:
$$\sqrt{a x^2 + b x + c} + \sqrt{d x^2 + e x + f} - \sqrt{g x^2 + h x + i} = 0 $$ And I am stuck, can't get x out.