Question
I need to get the the point Q of a cubic (2d) bezier curve B(t) where the line from point Q to another given point P intersects perpendicular with the bezier curve.
- I know: P, B(t)
- I look for: Q (basically I want to have the slope of g but I can easily calculate this when I know Q, but the slope of g is enough)
What I did until now (you can skip this)
Note that I think this ansatz is wrong. This is only included for completeness.
I tried to solve this with my (basic) knowledge of mathematics but I cannot finish it. This is what I have now (please don't too strict with the notation, I'm not very good in this):
The following formulas will be expressed as y(x) to get one result this has to be calculated for y(x) and x(y). The point P is the control point, Q is the point where the line g(x) from Q to P is perpendicular on the bezier curve B(t) = (x, y)T. The expression for the line g(x) can be retrieved by
where B(x) is the bezier curve in Cartesian coordinates, B'(x) the derivative (in Cartesian coordinates) and k is the intersection with the y axis. To get the slope of g(x) one has to solve
To calculate B(x) one has to solve B(t) for t and then plugging it back in B(t). So in each point on the bezier curve there is the relation
which also applies for the derivative B'(t).
The derivative of B(t) is (according to wikipedia)
Solving this for t (with wolfram alpha) results in
where a0 = (P1 - P0)x, a1 = (P2 - P1)x and a2 = (P3 - P2)x. Plugging the *ti*s back in B(t) results in (wolfram alpha for t1, wolfram alpha for t2, wolfram alpha for t3)
Now the next thing would be to use y = B'(x) and the second equation and eliminate x but I have no idea how and I don't even know if this is possible.