1
$\begingroup$

I have a cubic bezier curve, with the control points $P_0, P_1, P_2, P_3 \in\mathbf{R}^3 $

If I would like to walk from $P_0$ to $P_3$, then to calculate my current position I just linearly interpolate $t \in \mathbf{R}$ from $0 \to 1$ and call this function:

$$ \mathbf{B}(t)=(1-t)^3\mathbf{P}_0+3(1-t)^2t\mathbf{P}_1+3(1-t)t^2\mathbf{P}_2+t^3\mathbf{P}_3 $$

How should I transform $t$ to walk from $P_0$ to $P_3$ the same speed?

I mean if $ |t_x - t_y | = | t_a - t_b |$ then the arclength between $ \mathbf{B}(t_x) $ and $ \mathbf{B}(t_y) $ should equal to the length between $ \mathbf{B}(t_a) $ and $ \mathbf{B}(t_b) $

$\endgroup$
2
$\begingroup$

The velocity of the walker (in the first parametrization you have written) is $$ \mathbf{B}'(t)=-3(1-t)^2\mathbf{P}_0+3(3t^2-4t+1)\mathbf{P}_1+3t(2-3t)\mathbf{P}_2+3t^2\mathbf{P}_3. $$ From this, you can obtain the arclength as $$ s(t)=\int_0^t\|\mathbf{B}'(u)\|\ du. $$ In general the integrand is a messy expression depending very precisely on the control points, and there is most likely no elementary antiderivative for points in general position.

There is no simple expression for the arclength function. Perhaps a numerical integration suffices for the application you are interested in. Then one would proceed by finding the inverse function of $s(t)$, writing $t=t(s)$. Then the arclength parametrization is $\mathbf{B}(t(s))$.

$\endgroup$
  • $\begingroup$ How is it possible to approximate it? $\endgroup$ – Iter Ator Apr 16 '17 at 23:43
  • 1
    $\begingroup$ Using numerical integration, one would (for instance) approximate the integral by a finite sum, with a small mesh size. You can also numerically compute an approximation to $t(s)$, by taking for each $s$ in some mesh of points, the first $t$ value for which the integral is larger than your choice of $s$. This is easy to code by hand, or use any numerical integration package. $\endgroup$ – pre-kidney Apr 16 '17 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.