7
$\begingroup$

I have a cubic Bezier curve, and I need to divide it and create same curve between point on the original curve and the end point of the original curve.

From my research, I found the DeCasteljau algorithm helps in doing this. But, to use this algorithm, I need to know the '$t$' value at the dividing point.

Can anyone please help me out to find '$t$' at a given point on a cubic Bezier curve

I need to find the value of '$t$' at a given point B.

$\endgroup$
  • 2
    $\begingroup$ It's not at all clear what you're trying to do. Can you add a diagram? $\endgroup$ – Peter Taylor Oct 15 '13 at 12:17
  • $\begingroup$ If you cannot add a diagram, a more thorough description of what you are trying to do would really help others understand the question. $\endgroup$ – Carl Mummert Oct 15 '13 at 12:50
  • $\begingroup$ He has a point on a cubic Bezier curve, and he wants to find the corresponding parameter value, $t$. This parameter value is needed as input to the de Casteljau algorithm, which he wants to use to divide the curve at the given point. Seems pretty clear to me. $\endgroup$ – bubba Oct 16 '13 at 0:33
  • $\begingroup$ If the question is re-opened, I would be happy to answer it for you. One approach is just brute-force numerical root-finding. The more clever approach uses resultants and "inversion". See sections 17.4 through 17.6 of these notes: cagd.cs.byu.edu/~557/text/ch17.pdf. $\endgroup$ – bubba Oct 16 '13 at 0:46
  • $\begingroup$ Actually, there are two "inversion" algorithms. They are described on pages 200-202 of the reference I gave above. $\endgroup$ – bubba Oct 16 '13 at 4:42
6
$\begingroup$

Suppose we let $\mathbf{P}(t)$ be the Bezier curve, and let the given point be $\mathbf{B}$.

In theory, we want to find a value of $t$ such that $\mathbf{P}(t) = \mathbf{B}$. If you write out the $x$ and $y$ components separately, this will give you two cubic equations, which should have a common root, $t$.

But, in floating point arithmetic, $\mathbf{B}$ will be some small distance away from the curve, and we need to accomodate this. So, a better approach is to find the point on the curve that is closest to $\mathbf{B}$. In other words, find the value of $t$ that minimises the distance from $\mathbf{B}$ to $\mathbf{P}(t)$. At the point where this happens, the vector $\mathbf{P}(t) - \mathbf{B}$ will be perpendicular to the curve tangent, so $$ (\mathbf{P}(t) - \mathbf{B}) \cdot \mathbf{P}'(t) = 0 $$ Since $\mathbf{P}(t)$ is cubic and $\mathbf{P}'(t)$ is quadratic, this is an equation of degree 5 in $t$, which you can solve using your favorite numerical root-finder. This is the brain-dead brute force approach.

Now a smarter way ...

If you look in these notes by Tom Sederberg, you will find some techniques for "inversion" of polynomial and rational curves, based on the use of resultants. Specifically, on page 200, you will find a formula for doing "inversion" of a cubic curve written in Bezier form, and there's a nice worked example on page 201. This is exactly what you need.

As I mentioned above, you will often meet cases where the given point $\mathbf{B}$ is not exactly on the curve. You can apply the inversion formula, anyway, and it will give you some value of $t$. I'm not 100% sure what point this value of $t$ represents. I don't think it's the point on the curve that's closest to $\mathbf{B}$, but it should be good enough if $\mathbf{B}$ is already very close to the curve.

$\endgroup$
  • $\begingroup$ You don't happend to have that PDF around? The link seems broken. $\endgroup$ – netigger Oct 14 '18 at 17:11
  • $\begingroup$ Try this one. I think it's still chapter 17, but rhe page numbering might be a bit different. scholarsarchive.byu.edu/facpub/1 $\endgroup$ – bubba Oct 15 '18 at 1:44
  • $\begingroup$ @netigger: Chapter 17 is still what you need. $\endgroup$ – bubba Oct 15 '18 at 2:25
  • $\begingroup$ Thank you! @bubba $\endgroup$ – netigger Oct 15 '18 at 8:04
1
$\begingroup$

This is function for cubic bezier

$p = p_0(1 - t)^3 + 3p_1t(1 - t)^2 + 3p_2t^2(1 - t) + p_3t^3$

It can be reaarange into

$ p = p_0(1 - 3t + 3t^2 - t^3) + 3p_1(t - 2t^2 + t^3) + 3p_2(t^2 - t^3) + p_3t^3 \\ t^3(p_3 - 3p_2 + 3p_1 - p_0) + t^23(p_2 - 2p_1 + p_0) + t3(p_1 - p_0) + p_0 - p = 0 $

From this point it's a cubic equation for $x$ and $y$

You can find $t$ from $x$ and cubic equation will result in 3 possible values. Then you put $t$ back into function to get 3 $y$ and select a value close to the $y$ you put in

$\endgroup$

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.