1

I want to create a smooth curve that starts at point $P_0 = (Px_0, Py_0)$ with normalized tangent $T_0 = (Tx_0, Ty_0)$ (where $\sqrt{Tx_0^2 + Ty_0^2} = 1$) and with curvature $κ_0$ (where positive values are in the opposite direction relative to the normal and negative values are in the same direction as the normal), and which ends at point $P_1 = (Px_1, Py_1)$ with normalized tangent $T_1 = (Tx_1, Ty_1)$ and with curvature $κ_1$. That is, a parametric curve $P(t)$ where

  • $P(0) = P_0 = (Px_0, Py_0)$
  • $P(1) = P_1 = (Px_1, Py_1)$
  • $κ(0) = κ_0$
  • $κ(1) = κ_1$
  • $T(0) = T_0 = (Tx_0, Ty_0)$ where $\sqrt{Tx_0^2 + Ty_0^2} = 1$
  • $T(1) = T_1 = (Tx_1, Ty_1)$ where $\sqrt{Tx_1^2 + Ty_1^2} = 1$

Note that curvature is calculated as $κ(t) = \frac{Px'(t) Py''(t) - Px''(t) Py'(t)}{\left(\sqrt{Px'(t)^2 + Py'(t)^2}\right)^3}$, while the normalized tangent vector is calculated as $T(t) = \frac{P'(t)}{\sqrt{Px'(t)^2 + Py'(t)^2}}$.

The video "The Continuity of Splines" by Freya Holmér implies that one approach to creating my desired curve is to put together a polynomial equation of degree five, with six unknown variables to go with the six constraints, giving $P(t) = a × t^5 + b × t^4 + c × t^3 + d × t^2 + e × t + f$. To have $P(0) = P_0$, it is easy to see that the variable $f$ must be $P_0$, giving $P(t) = a × t^5 + b × t^4 + c × t^3 + d × t^2 + e × t + P_0$.

However, I can't figure out how to find the values of the other five variables given the constraints I have. The definitions for the curvature and tangent seem to be too complicated to plug in nicely. Can this be done? Is there an easy way that I'm missing, is it tricky but doable, or is it actually impossible?

Lawton
  • 1,759
  • 7
  • 18

1 Answers1

1

This problem was addressed in

High accuracy geometric Hermite interpolation
Carl de Boor, Klaus Höllig, Malcolm Sabin
Computer Aided Geometric Design
Volume 4, Issue 4, December 1987, Pages 269-278

There is an open-access version of the paper here.

Their technique produces a cubic curve, not the quintic suggested by Freda Holmér. There is not always a cubic solution, but usually there is.

Let’s use $p_0$, $p_1$, $p_2$ and $p_3$ to denote the control points of the cubic. We already know $p_0$ and $p_3$, so we just need to find $p_1$ and $p_2$. We are given the initial tangent direction, $d_0$, so we know that $p_1$ must be $p_0 + \delta_0*d_0$, for some (unknown) value of $\delta_0$. Similarly, we have $p_2 = p_3 - \delta_1*d_1$, for some (unknown) value of $\delta_1$. We just have to calculate $\delta_0$ and $\delta_1$. We do that by solving the equations (Q) given on page 2 of the paper. The equations reduce to a single quartic, which can be solved numerically or by the usual formulas. See here.

Once we have $p_0$, $p_1$, $p_2$ and $p_3$, the equation of the curve is given by the standard Bézier curve formula, which is given in the paper at the bottom of the first page.

Unit tangents and curvatures don’t give you enough info to uniquely define a quintic.

bubba
  • 43,483
  • 3
  • 61
  • 122
  • I read the paper you linked, and from the figures it looks like it gives the result I want, but I can't figure out how to get the actual parametric equation they use. Can you explain? – Lawton Jan 25 '23 at 16:16
  • I added some explanation. – bubba Jan 26 '23 at 04:48
  • I can see what you're saying, but I still can't figure out how to solve the equations (Q) to get standalone expressions for $δ_0$ and $δ_1$ in terms of position $p_i$, tangent $d_i$, and curvature $κ_i$. The paper keeps defining new variables as combinations of previously-defined variables, but they always depend on each other in such a way that trying to solve for one requires restricting the value of the other to a constant instead of a function of $p_i$, $d_i$, and $κ_i$. What am I missing? – Lawton Jan 26 '23 at 14:45
  • The equations (Q) are two quadratic equations involving $\delta_0$ and $\delta_1$. There is no closed-form solution, so you will need to use numerical methods to solve them, as the paper says. – bubba Jan 26 '23 at 23:06
  • See this question: https://math.stackexchange.com/questions/2295710/intersection-of-two-parabolas – bubba Jan 26 '23 at 23:12
  • I saw that the paper said solutions were "easily computed numerically", but I didn't realize they meant the solutions could ONLY be computed numerically. There are really no closed-form solutions? – Lawton Jan 27 '23 at 00:34
  • The only way to get a closed-form solution is to solve a quartic. The formulas for doing this are pretty horrible and difficult to code. You’re usually better off using numerical methods. – bubba Jan 27 '23 at 03:37
  • Let's say I do want to go through the process of solving the quartic. – Lawton Jan 27 '23 at 17:29
  • For the quartic solving approach, see the answers to this question: https://math.stackexchange.com/questions/2295710/intersection-of-two-parabolas – bubba Jan 28 '23 at 02:08
  • I think I'm making progress, but I've hit a stumbling block. The paper defines a vector cross product as $a × b := x(a) y(b) − y(a) x(b)$, where $x(a)$ is the $x$-component of vector $a$ and $y(a)$ is the $y$-component of vector $a$. So far, so good. However, when working through the algebra of solving the quartic, there are instances where the tangent vectors get squared or cubed. How do I deal with that? Using the cross-product-definition of vector multiplication and the repeated-multiplication-definition of exponentiation, $d_0^2 = x(d_0) y(d_0) − y(d_0) x(d_0) = 0$. Is that correct? – Lawton Jan 28 '23 at 17:10
  • Cubing a vector makes no sense, obviously. Squaring is pretty dubious, too. – bubba Jan 28 '23 at 23:56
  • After you have evaluated the cross products, everything in equations (Q) is just a number. No vectors. – bubba Jan 28 '23 at 23:59
  • Ah, evaluate the cross products before doing the rest of the algebra. That makes more sense. I think I've almost got it, but when I plot the resulting curve $p(t)$, the curvature at $t = 1$ does not equal $κ_1$. The curvature at $t = 0$ DOES equal $κ_0$, the tangent vectors work, and the positions line up; the only problem is $κ_1$. I've gone over all the equations and I can't figure out what's gone wrong. – Lawton Jan 30 '23 at 14:22
  • Well, I re-did it from scratch and now all the constraints are followed correctly. Not sure where things went wrong the first time, but oh well. Now the only issue I see is that the equations break if the tangent vectors at the start and end are 180° apart, which causes $d_0 × d_1 = 0$ and leads to division by zero, and they also break if $κ_0 = 0$ and/or $κ_1 = 0$ for the same reason. Playing around with the variables it seems like there is a well-behaved limit for all three situations, I just need to find it. Do you have any suggestions for finding the limit of these equations? – Lawton Jan 30 '23 at 15:07