3

If I am given n+1 control point Pi(xi,yi), Po .... Pn , how do I construct a parametric relationship to draw a curve ?

From what I understand , a parametric relationship is that you can express x and y in term of t, such as x(t) and y(t). I think, if I can use various t's put into the x(t) and y(t) , I will have many points x,y that I can draw a curve. However I don't know how to figure out the relationship between x,y, t using cubic B spline. Please help.

Peter
  • 2,015
  • I would also be interested in how to do that in higher dimensions, that means how to construct a cubic spline interpolation which is $C^{1}$ and almost everywhere $C^{2}$ (and such that the second derivative would be localy constant) – Max Feb 22 '14 at 22:31
  • 1
    Did you check the wikipedia page? There the linear system you have to solve is detailed. Construct a separate spline for the x and y coordinate respectively, that is, for the samples $(k,x_k)$ and $(k, y_k)$. – Lutz Lehmann Feb 22 '14 at 22:31
  • I did check the wikipedia page but I don't really understand what they are saying. – Peter Feb 23 '14 at 00:17

1 Answers1

4

If you want to use the points $\mathbf{P}_0, \ldots, \mathbf{P}_n$ as control points of a spline curve, then the curve is just $$ \mathbf{C}(t) = \sum_{i=0}^n B_i(t)\mathbf{P}_i $$ where the $B_i$ are b-spline basis functions. This formula allows you to compute points on the curve, which you can then use to draw it. Note that, in general, this curve will not pass through the points $\mathbf{P}_0, \ldots, \mathbf{P}_n$.

If you want your curve to pass through the points $\mathbf{P}_0, \ldots, \mathbf{P}_n$, then you first need to construct an interpolating spline.

You will need to use a parametric spline that gives $x$ and $y$ as functions of some parameter $t$. To construct the curve, you must first assign a parameter value $t_i$ to each point $P_i$. These parameter values are entirely fabricated -- they are not an intrinsic part of the original interpolation problem. Furthermore, different choices for these parameter values will produce significantly different curves. The usual approach is to choose them so that $t_{i+1}-t_i$ is equal to the chord-length between the points $\mathbf{P}_i$ and $\mathbf{P}_{i+1}$.

You solve systems of linear equations to get the $x$ and $y$ coordinates of control points $\mathbf{Q}_0, \ldots, \mathbf{Q}_n$. Then the equation of the curve is again $$ \mathbf{C}(t) = \sum_{i=0}^n B_i(t)\mathbf{Q}_i $$

Note that we haven't really made use of the fact that the points $\mathbf{P}_i$ or $\mathbf{Q}_i$ are 2D; this same construction will work in 3D, or in fact in any finite-dimensional space.

A good reference is this web site.

bubba
  • 44,617
  • Wow, I really appreciate your effort. You have been helping me with the other question as well. – Peter Feb 23 '14 at 02:24
  • How do we define $B_i(t)$, specifically what is the formula for $B_i(t)$? – Wolfy Oct 26 '15 at 14:32
  • In general, there are no reasonable closed-from formulae for the basis functions. They are constrcucted recursively, starting with lower degrees and working up to higher degrees. Look up any reference on "b-spline basis functions". – bubba Oct 26 '15 at 15:13