Line uniting 2 segments at a specific ratio and crossing a point between the two 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.
see image for clarification
$\ 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.
 A: Note that $\{t_l, t_r, b_l, b_r\}$ defines a quadrilateral, call it $Q$. From here, we can clarify the requirements a bit:  


*

*Instead of constraining $t$ "above" $b$, we can instead constrain ourselves to cases where $Q$ is simple (no intersecting edges) and convex. This characterisation also excludes degenerate cases such as when $t$ and $b$ don't form a quadrilateral.

*Point $p$ must be an interior point of $Q$.


We get some nice properties when we map $Q$ to the unit square, $Q'$, such that $t_l = (0,1)$, $t_r = (1,1)$, $b_l = (0,0)$, and $b_r = (1,0)$.


*

*The x coordinate of the projected point $p' = (p'_x, p'_y) \in [0,1]\times [0,1]$ is the ratio.

*The line segment from $(p'_x,0)$ to $(p'_x,1)$ is our solution after applying the inverse map.

*Such a line exist since $p'$ is also an interior point of the unit square. It is also unique since the (projected) line must be vertical in order to have the same ratio on $t'$ and $b'$, there is only one such vertical line passing through $p'$.


Perspective projection should do for the mapping above. The mathematics will be a little more involved and I am not too familiar with it so you may consider this answer as a guide that specifically handles this particular step.
A: Bilinear interpolation in a quadrilateral is the thing that I needed, see http://reedbeta.com/blog/quadrilateral-interpolation-part-2/.
