How to efficiently sample $y$ in intervals of $\Delta x$ in an "ascending" cubic Bézier curve?

62 Views Asked by At

For a cubic Bézier curve defined by control points $\boldsymbol{P_0}$, $\boldsymbol{P_1}$, $\boldsymbol{P_2}$ and $\boldsymbol{P_3}$ with the formula

$\boldsymbol{B}(t) = (1 - t)^3\boldsymbol{P_0} + 3(1 - t)^2t\boldsymbol{P_1} + 3(1 - t)t^2\boldsymbol{P_2} + t^3\boldsymbol{P_3}$

we can get a point corresponding to any $t \in [0, 1]$. However, from what I've gathered, algebraically solving for either one of the coordinates becomes very tedious and costly, at least for a general solution.

Now, suppose we have a two-dimensional curve $\boldsymbol{B}(t) = (x,y)$ with the specific constraint that $\frac{dx}{dt} > 0$ for all $0 \leq t \leq 1$, i.e. the curve can progress to the positive x direction, but never "straight up/down" or "backwards", is there an efficient algorithm (/algebraic manipulation trick) to sort of "sample" the $y$ of the curve with respect to a constant interval $\Delta x$ that can leverage this property?

(Please excuse me for the sloppy math terminology, I'm no mathematician)

1

There are 1 best solutions below

0
On

For any specific value of $x=x_0$, where

$x_0 = P_{0x} + 3(P_{1x}-P_{0x})t + 3(P_{2x}-2P_{1x}+P_{0x})t^2 + (P_{3x}-3P_{2x}+3P_{1x}-P_{0x})t^3$

you can solve for the value of $t$ using Cardano's formula (see link here) and you shall always find one real root since your curve never goes straight up/down or backwards. Once you have $t$ value, you can evaluate the corresponding $y$ value.