0

Well, I'm using Wolfram Mathematica for a universitary project, as the title says. I need to define the trajectory of an object, which moves in a tri-dimensional space. I chose eight control points and I got the right curve with "BSplineCurve" command, plotted with "Graphics3D". But I need an approximate function (which should be my curvilinear abscissa) for that curve in order to get its parametric equations, and I don't understand how to do it. I should find something like: s=s(t) -> x=x(s), y=y(s), y=y(s). Here in the screenshot you can see the spline curve and what I got trying the command "BSplineFunction". Can anyone help me?

  • This seems more appropriate for the Mathematica SE. See in particular, https://mathematica.stackexchange.com/questions/19229/convert-bsplinefunction-into-two-interpolating-functions, which appears to be asking a similar question. – amd Jan 13 '18 at 23:51

1 Answers1

0

The reference for BSplineFunction says it constructs a B-spline using the supplied list as control points.

The B-spline article at MathWorld shows the equation of the curve, $$\mathbf{C}(t) = \sum_{i=0}^{n} \mathbf{P}_i N_{i, p}(t)\tag{1}\label{NA1}$$ where $p$ is the degree of the spline, $\mathbf{P}_0$ through $\mathbf{P}_n$ are your control points, and $N_{i, p}(t)$ are the basis functions (evaluated at $t$): $$\begin{array}{l} N_{i, p} = \begin{cases} 1 & \text{ if } t_i \le t \lt t_{i+1} \text{ and } t_i \lt t_i+1 \\ 0 & \text{ otherwise } \end{cases} \\ N_{i, j} = \frac{t - t_i}{t_{i+j} - t_i} N_{i, j-1}(t) + \frac{t_{i+j+1} - t}{t_{i+j+i} - t_{i+1}} N_{i+1, j-1}(t) \end{array}$$

The documentation even mentions that the Mathematica function BSplineFunction implements these. The details on the reference page say that by default, the BSplineFunction returns cubic splines, i.e., $p = 3$, with the knots uniformly within $0 \dots 1$, with additional knots added so that the spline starts at the first control point, and ends at the last control point.

If you have eight control points, then $n = 7$. If the spline is cubic, then $p = 3$. The degree of the spline is defined by $p = m - n - 1$, so $m = 9$, and you have a knot vector with twelve elements ($m = 11$). If the knots are uniformly within $0 \dots 1$, except with start and end knots, the knot vector is $$\mathbf{T} = \left\lbrace t_0, t_1, t_2, \dots, t_9, t_10, t_11 \right\rbrace = \left\lbrace 0, 0, 0, \frac{1}{7}, \frac{2}{7}, \frac{3}{7}, \frac{4}{7}, \frac{5}{7}, \frac{6}{7}, 1, 1, 1 \right\rbrace$$

With these, you can find the explicit form of $\eqref{NA1}$, by evaluating $N_{i,j}$ for $i = 0 \dots 7$ and $j = 0 \dots 3$.

Note, however, that $\mathbf{C}(t)$ is defined piecewise.

If you prefer, you can use "knot insertion" (as outlined by this answer by Bubba) to elevate each knot to degree 3 (yielding a knot vector $\mathbf{T} = \left\lbrace 0, 0, 0, \frac{1}{7}, \frac{1}{7}, \frac{1}{7}, \frac{2}{7}, \frac{2}{7}, \frac{2}{7}, \dots, 1, 1, 1 \right\rbrace$), which decomposes to cubic Bézier curves.

If you instead want a non-piecewise polynomial form, $$\mathbf{C}(t) = \sum_{i=0}^{N} \mathbf{Q}_i t^i$$ i.e. $$\mathbf{C}(t) = \left( x(t), y(t), z(t) \right)$$ $$\mathbf{Q}_i = \left( X_i , Y_i , Z_i \right)$$ $$x(t) = \sum_{i=0}^{N} X_i t^i$$ $$y(t) = \sum_{i=0}^{N} Y_i t^i$$ $$z(t) = \sum_{i=0}^{N} Z_i t^i$$ you need an approximation, fitting this form to a set of sampled points in your original curve. (I do not personally use Mathematica, so I don't know exactly how you'd do this, but perhaps the Fit function is a good place to start. The spline looks reasonably simple/smooth, so a lot of uniformly distributed points on it should work fine.)

What I do not understand, is why you didn't begin with this form in the first place. Seems like a convoluted way to do it.