Please see this answer. It covers the case of a cubic Bezier curve, but quadratic curves are even simpler, of course.
As that answer states, this "inversion" problem is covered thoroughly in
these notes by Tom Sederberg. He provides techniques for "inversion" of polynomial and rational Bezier curves, based on the use of resultants.
Specifically, on page 200, you will find a formula for doing "inversion" of a quadratic curve written in Bezier form -- equation (17.5). If you look closely at the formulae for his quantities $l_{ij}$, you will see that they represent areas of triangles. This is to be expected, in view of my comment about barycentric coordinates above.
For both quadratic and cubic curves, the inversion equation is linear, so it just involves simple algebraic operations -- no quadratic equation solving, and no square roots.
Suppose we have a quadratic Bezier curve with control points $\mathbf{P}_i = (x_i, y_i, z_i)$, where $i=0,1,2$, and we have a given point $\mathbf{P} = (x, y, z)$. Then, using Sederberg's techniques, the "$t$" value corresponding to the point $\mathbf{P}$ can be calculated using the following simple code:
c10 = (x - x1)*(y - y0) - (x - x0)*(y - y1)
c20 = (x - x2)*(y - y0) - (x - x0)*(y - y2)
t = c10/(c10 - 0.5*c20)
Here we use the symbols $c_{ij}$ instead of the $l_{ij}$ in Sederberg's notes, because the letter "l
" causes confusion in code. Note that the computation requires nothing more than a few subtractions and multiplications, and one division.