I'm trying to write a program that can detect whether the mouse is inside the parabola defined by three Bezier control points. I first tried doing this by looping through each line in the "string art" Bezier and then detecting whether the mouse is on the correct side of each line. If it's on the correct side of each line, then it's inside the parabola. The two problems of that was that it was very slow and that it had a limited resolution. So I wanted to figure out a computationally simpler approach.
Now what I want to do is find the equation for the parabola created by the bezier and use an inequality to determine whether the mouse is inside or outside the parabola. I found this similar question, but the conclusion was that it was impossible as the parabola will almost always be rotated at some angle. However, according to this wikipedia article there is a general formula for a parabola that accounts for such rotations. I also found this question which again had the same problem.
Thus, I want to find out how to take the parametric equation of a bezier:
$P = A(1 - t)^2 + 2Bt(1 - t) + Ct^2$
(Where $P$ is a point on the Bezier and $A$, $B$, and $C$ are control points)
and turn it into an equation for a parabola probably of the form
$\frac{(ax+by+c)^2}{a^2+b^2} = (x-f_1)^2 + (y-f_2)^2$
The answer to this question suggests using implicitization to do basically the same thing, but the example (section 1.4.2) it gives is only for cubic beziers, and I don't know how to do implicitization myself to figure it out for a quadratic bezier. The other answer to that question includes a working example, but I can neither figure out how it works nor successfully replicate it on my own, partly because the link the article where the algorithm came from is down and partly because I'm just not good enough at math.
So how could I find an equation for the parabola created by a quadratic Bezier such that I could turn it into an inequality to determine whether a point is on the inside or outside of that curve?
(PS. If whatever solution you come up with only works with $0 \le t \le 1$ without coming up with an equation for the entire parabola, that's fine since my original program only needs to detect whether the mouse is in a 90 degree wedge bound by the section of the parabola created by the bezier)
Let
$$P_t = A(1 - t)^2 + 2Bt(1 - t) + Ct^2\tag{1}$$
be the parametric equation of Bézier curve $(B)$.
Here is a solution based on barycentric coordinates $(a,b,c)$ of point $M$ to be tested ; it relies on the following formula :
$$\left(\dfrac{1-t}{t}\right)^2 \ \ \iff \ \ t=\dfrac{1}{1+\sqrt{a/c}}\tag{2}$$
giving the value of parameter $t$ such that point
$$P_t = \text{line BM } \ \cap \ (B)$$
It remains plainly to test whether $BM/BP_t$ is $<1$ or $>1$.
Here is a figure showing it on random points (Matlab program) :
Explanation : Let us recall that (1) expresses naturally
$$(1 - t)^2, \ \ 2t(1 - t), \ \ t^2$$
as the barycentric cordinates of $P_t$ with respect to triangle $ABC$.
Let $(a,b,c)$ be the barycentric coordinates of point $M$.
As all points $(a',b',c')$ of line $BM$ are equally attracted by $A$ and by $C$, they are characterized by $a'/c'=a/c$, explaining relationship (2).
Now, how can we "short-circuit" barycentric coordinates ? Plainly by expressing them in "areal" terms :
$$a=\text{area MBC}, \ \ b=\text{area AMC}, \ \ c=\text{area ABM}\tag{3}$$
(no normalization needed for our purpose ; important : these areas are oriented areas).
Summary : being given $M$, one has to
1) compute ratio $ a/c = \text{area MBC}/\text{area ABM}$ (areas obtained by computing determinants)
2) apply formula (2) obtain $t$ (formula (2))
3) test whether $BM/BP_t \ \binom{<}{\geq}1.$
Remark : testing whether $M$ is inside triangle $ABC$ is easy using criteria $b=\text{area AMC}>0$ .