Suppose you have the following three points A, B, and C, as shown in the following figure:

Points are always sorted according to their vertical offset, so the highest point is always A. Sometimes B and C can have the same y coordinate.
I am trying to find the x coordinate for point D. I can find the Y coordinate for D by interpolating the points Ay and Cy at (By / (Cy - Ay)). I do my interpolation using the following formula (in C ++)
float linearInterpolation(float a, float b, float t) { return a + (t * (b - a)); }
In other words, Dy = linearInterpolation (Ay, Cy, (By - Ay) / (Cy - Ay))
So, to summarize, my question is: how do I find Dx?
thanks
-
Answer:
To clarify, here is a solution that was proposed and worked:
Dx = Ax + (By - Ay) * (Cx - Ax) / (Cy - Ay); Dy = By;
As the picture below:

source share