TITLE: Cubic Bezier curve and a straight line intersection
QUESTION [7 upvotes]: Suppose that two ends of a cubic Bezier curve is connected by a straight line.  Is there a simple way to find out whether this straight line intersects the Bezier curve (apart from the endpoints)? If it intersects then what will be the corresponding Bezier curve parameter's value?

REPLY [5 votes]: I just wanted to add to g.kov's good derivation, that the $t$ value is the parameter for the Bézier segment, not the line, so the range of $0 < t < 1$ stated above doesn't guarantee the the intersection is on the line segment between A and D, only that it is on the Bézier segment.  The intersection could fall outside of the line segment, as pictured:
http://i.stack.imgur.com/ER2SH.png
Following the same substitution as above, $s$ can be derived as:
$$
s = \frac{\left(b_y d_x-b_x d_y\right) \left(d_x \left(3 b_x c_y^2-3 b_y c_x c_y-2 b_x b_y d_y\right)+d_y \left(-3 b_x c_x c_y+3 b_y c_x^2+b_x^2 d_y\right)+b_y^2 d_x^2\right)}{\left(d_x \left(b_y-c_y\right)+d_y \left(c_x-b_x\right)\right){}^3}
$$
Only when both $0 < s < 1$ and $0 < t < 1$ is there point of intersection between the curve and line segment.