Gradient of a rational Bezier curve

668 Views Asked by At

I'd appreciate help working out the gradient of a rational Bezier curve $C = (\,x(t) \,, \,C_y(t) \,)$. I know that the gradient $g$ of a the parametric curve is

$$ g(t) = \left( \frac{dy(t)}{dt} \right) \left( \frac{dx(t)}{dt} \right)^{-1} $$

And from equation (10) of the paper Derivatives of rational Bezier curves (by M. S. Floater) I know that

$$ \frac{dx(t)}{dt} = \frac{ \omega_{0,n-1}(t) \; \omega_{1,n-1}(t) }{\omega_{0,n}^2}( \; x_{1,n-1}(t) \; - \; x_{0,n-1}(t) \; ) $$

and

$$ \frac{dy(t)}{dt} = \frac{ \omega_{0,n-1}(t) \; \omega_{1,n-1}(t) }{\omega_{0,n}^2}( \; y_{1,n-1}(t) \; - \; y_{0,n-1}(t) \; ) $$

where $x_{i,j}$ and $y_{i,j}$ are the coordinates of the control points of curve, obtained during recursive evaluation (I've taken some liberties with the notations used in the paper), from which I reason that

$$ g(t) = \frac{ y_{1,n-1}(t) \; - \; y_{0,n-1}(t) }{x_{1,n-1}(t) \; - \; x_{0,n-1}(t) } $$

So that for example if given a degree 3 rational Bezier curve with control points $(0,0),(3,0)(6,5)(9,5)$ and corresponding weights $(1, 3 , 3 , 1)$,

$$ g(t) = \frac{40t^2 - 30t}{18t^2 - 9} $$

The (discontinuity) in plot of this equation (shown below) suggests that the formula for g(t) is incorrect, as Bezier curves do not have discontinuities.

enter image description here

Edit

The parametric equation(s?) of the example rational Bezier curve above is (are?)

$$ x(t) = \frac{5t^3+45(1-t)t^2}{t^3+9(1-t)t^2+9(1-t)^2t+(1-t)^3} $$

$$ y(t) = \frac{9t^3+54(1-t)t^2+27(1-t)^2t}{t^3+9(1-t)t^2+9(1-t)^2t+(1-t)^3} $$

and the plot (below) looks about right

enter image description here

1

There are 1 best solutions below

0
On

I haven't checked all your algebra, but your general approach looks correct.

The flaw in your reasoning is your statement that "Bezier curves don't have discontinuities". A (2D) Bezier curve is a mapping $t \mapsto (x(t), y(t)) = \mathbf{C}(t)$. It's true that this mapping is infinitely differentiable -- all its derivatives are continuous.

But this doesn't imply that the mapping $g(t) = y'(t)/x'(t)$ is continuously differentiable. In fact, $g(t)$ will have a discontinuity wherever $x'(t) = 0$ (i.e. wherever the curve has a vertical tangent).

It looks like there is some mistake in your computation of $g(t)$. Your expression for $g(t)$ will go to infinity when $t= \sqrt2$, which suggests that the curve has a vertical tangent when $t= \sqrt2$. But your picture of the curve looks correct, and clearly there is no place where its tangent is vertical.

Another reason your formula for $g(t)$ must be wrong -- when $t=1$ it should give $g(1)=0$, and it doesn't.