I am trying to understand the form of the determinants that I get when I try to calculate the self-intersection. Since I might have made some mistakes, I'm including the whole derivation:
Let $\vec{P}(t)$ be a cubic Bezier curve in two dimensions. In power basis: $$ \vec{P}(t)=(−\vec{A}+3\vec{B}−3\vec{C}+\vec{D})t^3+(3\vec{A}−6\vec{B}+3\vec{C})t^2+(−3\vec{A}+3\vec{B})t+\vec{A} $$ $$ =\vec{a}t^3+\vec{b}t^2+\vec{c}t+\vec{d}. $$ For a loop intersection to occur, there must exist $(t,s), t\neq s$ : $$ \vec{a}(t^3-s^3)+\vec{b}(t^2-s^2)+\vec{c}(t-s)=0 \quad\quad\quad/(t-s) $$ $$ \vec{a}(t^2+ts+s^2)+\vec{b}(t+s)+\vec{c}=0 $$ If I make the substitution $ u :=t+s/2$, I get: $$ a_x(u^2+\frac{3s^2}{4})+b_x(u+\frac{s}{2})+c_x=0 $$ $$ a_y(u^2+\frac{3s^2}{4})+b_y(u+\frac{s}{2})+c_y=0 $$ I can eliminate the quadratic term by doing $a_y(I)-a_x(II)$: $$ (a_yb_x - a_xb_y)(u+\frac{s}{2})+(a_yc_x-a_xc_y)=0 $$ $$ M:=a_yb_x - a_xb_y\quad\quad\quad N:=-(a_yc_x-a_xc_y) $$ $$ u=\frac{N}{M}-\frac{s}{2} $$ Substituting $u$ back: $$ \vec{a}\left[\left(\frac{N}{M}-\frac{s}{2}\right)^2+\frac{3s^2}{4}\right]+\vec{b}\frac{N}{M}+\vec{c}=0 $$ $$ \vec{a}\left[s^2 - \frac{N}{M}s+ \left(\frac{N}{M}\right)^2\right]+\vec{b}\frac{N}{M}+\vec{c}=0 $$ These quadratic equations have solutions: $$ s_i=\frac{1}{2a_i}\left( a_i\frac{N}{M}\pm\sqrt{D_i}\right) $$ $$ D_i=a_i^2\left(\frac{N}{M}\right)^2-4a_i\left(a_i\left(\frac{N}{M}\right)^2+b_i\frac{N}{M}+c_i\right) $$ And now I'm confused...
- Why did I end up with two quadratic equations? Shouldn't there be just one? My understanding is that $D = 0$ corresponds to the cusp shape, $D > 0$ to a loop intersection and $D < 0$ to no intersection.
- Furtheremore, I would like to understand what $M=0$ (which blows up the determinant) corresponds to. The expression for the curve being quadratic explains it only partly, i.e. when $a_x = a_y = 0$. What do the other conditions in: $$ M=a_yb_x - a_xb_y=0 $$ correspond to? (E.g. what is 'wrong' with $(b_x = b_y = 0)$, $(a_yb_x = a_xb_y)$?)
(1) $D_x$ and $D_y$ are almost identical:
So $D_x=a_x^2K$ and $D_y=a_y^2K$ where $K$ is common to both expressions. The $a_x^2$ or $a_y^2$ can be brought out of the square root, where it then cancels the other instances of $a_x$ or $a_y$: $$s_i=\frac{N/M\pm\sqrt K}2$$ There is only one quadratic equation for $s$ – the possible values for $s_x$ and $s_y$ are identical. Your interpretation of $D$ (essentially equivalent to my $K$) is correct though.
(2) Let $\vec P(t)=(x(t),y(t))$. If $M=0$ there are real $\lambda$ and $\mu$, not both zero, for which $\lambda x(t)+\mu y(t)$ is a linear polynomial (cubic and quadratic terms both cancel). The rotated curve $\vec Q(t)=\begin{bmatrix}\lambda&\mu\\-\mu&\lambda\end{bmatrix}\vec P(t)$ is then the graph of a single-variable (generically) cubic function $y=f(x)$. In short, $M=0$ implies $\vec P(t)$ has no self-intersections and at most one inflection point.
(3) Your method is not the most elegant way of deriving the self-intersection parameters. See my answer here.