/
BSpline.hpp
696 lines (587 loc) · 25.6 KB
/
BSpline.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/**
* @file BSpline.hpp
* @author Paul Furgale <paul.furgale@utoronto.ca>
* @date Fri Feb 11 13:51:57 2011
*
* @brief A class to facilitate state estimation for vehicles in 3D
* space using B-splines.
*
*
*/
#ifndef _BSPLINE_HPP
#define _BSPLINE_HPP
#include <sparse_block_matrix/sparse_block_matrix.h>
#include <vector>
#include <Eigen/Core>
#include <sm/assert_macros.hpp>
namespace bsplines {
class BiVector;
}
namespace Eigen {
namespace internal {
template<>
struct functor_traits<bsplines::BiVector>
{
enum { Cost = 1, PacketAccess = false, IsRepeatable = true };
};
}
}
namespace bsplines {
class BiVector {
enum { Cost = 1, PacketAccess = false, IsRepeatable = true };
private:
const int startIndex_;
const double endValue_;
const Eigen::VectorXd localBi_;
public:
BiVector(int startIndex, const Eigen::VectorXd & localBi, double endValue) : startIndex_(startIndex), endValue_(endValue), localBi_(localBi){};
double operator() (int i, int j = 0) const {
// kill unused parameter warning
static_cast<void>(j);
i -= startIndex_;
if(i < 0){
return endValue_;
}
if(i >= (localBi_.rows())){
return 0;
}
return i >= 0 ? localBi_(i): 0;
}
};
/**
* @class BSpline
*
* A class to facilitate state estimation for vechicles in 3D space using B-Splines
*
*/
class BSpline
{
public:
/**
* @class Exception
*
* A base class for BSpline exceptions.
*
*/
SM_DEFINE_EXCEPTION(Exception, std::runtime_error);
/**
* Create a spline of the specified order. The resulting B-spline will
* be a series of piecewise polynomials of degree splineOrder - 1.
*
* @param splineOrder The order of the spline.
*/
BSpline(int splineOrder);
/**
* A destructor.
*
*/
~BSpline();
/**
*
* @return The order of the spline
*/
int splineOrder() const;
/**
*
* @return The degree of polynomial used by the spline.
*/
int polynomialDegree() const;
/**
*
* @return the minimum number of knots required to have at least one valid time segment.
*/
int minimumKnotsRequired() const;
/**
* @param numTimeSegments the number of time segments required
* @return the number of coefficients required for a specified number of valid time segments.
*/
int numCoefficientsRequired(int numTimeSegments) const;
/**
* @param numTimeSegments the number of time segments required
* @return the number of knots required for a specified number of valid time segments.
*/
int numKnotsRequired(int numTimeSegments) const;
/**
*
* @param numKnots the number of knots.
* @return the number of valid time segments for a given number of knots.
*/
int numValidTimeSegments(int numKnots) const;
/**
*
* @return the number of valid time segments for a given for the current knot sequence.
*/
int numValidTimeSegments() const;
/**
* Return the basis matrix active on the \f$i^{\textup{th}}\f$ time segment.
*
* @param i The index of the time segment.
*
* @return The basis matrix active on the time segment.
*/
const Eigen::MatrixXd & basisMatrix(int i) const;
/**
*
* @return the time interval that the spline is well-defined on [t_min(), t_max()]
*/
std::pair<double,double> timeInterval() const;
/**
* Return the time interval of a single spline segment.
*
* @param i The index of the time segment
*
* @return the time interval of the ith spline segment.
*/
std::pair<double,double> timeInterval(int i) const;
/**
* Set the knots and coefficients of the spline. Each column of the coefficient matrix
* is interpreted as a single, vector-valued spline coefficient.
*
* @param knots A non-decreasing knot sequence.
* @param coefficients A set of spline coefficients.
*/
void setKnotsAndCoefficients(const std::vector<double> & knots, const Eigen::MatrixXd & coefficients);
/**
* Set the knots and coefficients of the spline. Each column of the coefficient matrix
* is interpreted as a single, vector-valued spline coefficient.
*
* @param knots A non-decreasing knot sequence.
* @param coefficients A set of spline coefficients.
*/
void setKnotVectorAndCoefficients(const Eigen::VectorXd & knots, const Eigen::MatrixXd & coefficients);
/**
* Sets the coefficient matrix from the stacked vector of coefficients.
*
* @param coefficients The stacked vector of coefficients.
*/
void setCoefficientVector(const Eigen::VectorXd & coefficients);
/**
*
* @return The stacked vector of coefficients.
*/
Eigen::VectorXd coefficientVector();
/**
* Sets the matrix of coefficients.
*
* @param coefficients
*/
void setCoefficientMatrix(const Eigen::MatrixXd & coefficients);
/**
* @return the current knot vector.
*/
const std::vector<double> knots() const;
/**
* @return the current knot vector.
*/
Eigen::VectorXd knotVector() const;
/**
* @return the current spline coefficient matrix. Each column of the coefficient matrix
* is interpreted as a single, vector-valued spline coefficient.
*/
const Eigen::MatrixXd & coefficients() const;
/**
*
* @return The number of total coefficients the spline currently uses
*/
int numCoefficients() const;
/**
* This is equivalent to spline.coefficients().cols()
*
* @return The number of vector-valued coefficient columns the spline currently uses
*/
int numVvCoefficients() const;
/**
*
* @return The minimum time that the spline is well-defined on.
*/
double t_min() const;
/**
*
* @return The maximum time that the spline is well-defined on. Because B-splines
* are defined on half-open intervals, the spline curve is well defined up
* to but not including this time.
*/
double t_max() const;
/**
* Evaluate the spline curve at the time t.
*
* @param t The time to evaluate the spline curve
*
* @return The value of the spline curve at the time t.
*/
Eigen::VectorXd eval(double t) const;
/**
* Evaluate the derivative of the spline curve at time t.
*
* @param t The time to evaluate the spline derivative.
* @param derivativeOrder The order of the derivative. This must be >= 0
*
* @return The value of the derivative of the spline curve evaluated at t.
*/
Eigen::VectorXd evalD(double t, int derivativeOrder) const;
/**
* Evaluate the derivative of the spline curve at time t and retrieve the Jacobian
* of the value with respect to small changes in the paramter vector. The Jacobian
* only refers to the local parameter vector. The indices of the local parameters with
* respect to the full paramter vector can be retrieved using localCoefficientVectorIndices().
*
* @param t The time to evaluate the spline derivative.
* @param derivativeOrder The order of the derivative. This must be >= 0
*
* @return The value of the derivative of the spline curve evaluated at t and the Jacobian.
*/
std::pair<Eigen::VectorXd, Eigen::MatrixXd> evalDAndJacobian(double t, int derivativeOrder) const;
/**
* Evaluate the derivative of the spline curve at time t and retrieve the Jacobian
* of the value with respect to small changes in the paramter vector. The Jacobian
* only refers to the local parameter vector.
*
* @param t The time to evaluate the spline derivative.
* @param derivativeOrder The order of the derivative. This must be >= 0
* @param a pointer to the Jacobian matrix to fill in
* @param a pointer to an int vector that will be filled with the local coefficient indices
*
* @return The value of the derivative of the spline curve evaluated at t.
*/
Eigen::VectorXd evalDAndJacobian(double t, int derivativeOrder, Eigen::MatrixXd * Jacobian, Eigen::VectorXi * coefficientIndices) const;
/**
* Get the local basis matrix evaluated at the time \f$ t \f$.
* For vector-valued spline coefficients of dimension \f$ D \f$
* and a B-spline of order $S$, this matrix will be \f$ D \times SD \f$
*
* @param t The time to evaluate the local basis matrix.
* @param derivativeOrder The derivative order to return (0 is no derivative)
*
* @return The local basis matrix evaluated at time \f$ t \f$
*/
Eigen::MatrixXd Phi(double t, int derivativeOrder = 0) const;
/**
* Get the local basis matrix evaluated at the time \f$ t \f$.
* For vector-valued spline coefficients of dimension \f$ D \f$
* and a B-spline of order $S$, this matrix will be \f$ D \times SD \f$
*
* @param t The time to evaluate the local basis matrix.
* @param derivativeOrder The derivative order to return (0 is no derivative)
*
* @return The local basis matrix evaluated at time \f$ t \f$
*/
Eigen::MatrixXd localBasisMatrix(double t, int derivativeOrder = 0) const;
/**
* Get the local coefficient matrix evaluated at the time \f$ t \f$.
* For vector-valued spline coefficients of dimension \f$ D \f$
* and a B-spline of order $S$, this matrix will be \f$ D \times S \f$.
* Each column of the resulting matrix corresponds to a single vector-valued
* coefficient.
*
* @param t The time being queried
*
* @return The local coefficient matrix active at time \f$ t \f$
*/
Eigen::MatrixXd localCoefficientMatrix(double t) const;
/**
* Return a map to a single coefficient column.
* This allows the user to pass around what is essentially a pointer
* to a single column in the coefficient matrix.
*
* @param i The column of the coefficient matrix to return. \f$ 0 \le i < \f$ coefficients().cols()
*
* @return A map to column i of the coefficient matrix.
*/
Eigen::Map<Eigen::VectorXd> vvCoefficientVector(int i);
/**
* Return a map to a single coefficient column.
* This allows the user to pass around what is essentially a pointer
* to a single column in the coefficient matrix.
*
* @param i The column of the coefficient matrix to return. \f$ 0 \le i < \f$ coefficients().cols()
*
* @return A map to column i of the coefficient matrix.
*/
Eigen::Map<const Eigen::VectorXd> vvCoefficientVector(int i) const;
/**
* Return a map to a single coefficient column.
* This allows the user to pass around what is essentially a pointer
* to a single column in the coefficient matrix.
*
* @param i The column of the coefficient matrix to return. \f$ 0 \le i < \f$ coefficients().cols()
*
* @return A map to column i of the coefficient matrix.
*/
template<int D>
Eigen::Map<Eigen::Matrix<double, D, 1> > fixedSizeVvCoefficientVector(int i)
{
SM_ASSERT_EQ_DBG(Exception,D,coefficients_.rows(), "Size mismatch between requested vector size and actual vector size");
SM_ASSERT_GE_LT(Exception, i, 0, coefficients_.cols(), "Index out of range");
return Eigen::Map<Eigen::Matrix<double, D, 1> >(&coefficients_(0,i),coefficients_.rows());
}
/**
* Return a map to a single coefficient column.
* This allows the user to pass around what is essentially a pointer
* to a single column in the coefficient matrix.
*
* @param i The column of the coefficient matrix to return. \f$ 0 \le i < \f$ coefficients().cols()
*
* @return A map to column i of the coefficient matrix.
*/
template<int D>
Eigen::Map<const Eigen::Matrix<double, D, 1> > fixedSizeVvCoefficientVector(int i) const
{
SM_ASSERT_EQ_DBG(Exception,D,coefficients_.rows(), "Size mismatch between requested vector size and actual vector size");
SM_ASSERT_GE_LT(Exception, i, 0, coefficients_.cols(), "Index out of range");
return Eigen::Map< const Eigen::Matrix<double, D, 1> >(&coefficients_(0,i),coefficients_.rows());
}
/**
* Get the local coefficient vector evaluated at the time \f$ t \f$.
* For vector-valued spline coefficients of dimension \f$ D \f$
* and a B-spline of order $S$, this vector will be \f$ SD \times 1 \f$
* Evaluating the B-spline at time t, eval(t,O) is equivalent to evaluating
* Phi(t,O) * localCoefficientVector(t)
*
* @param t The time being queried
*
* @return The local coefficient vector active at time \f$ t \f$
*/
Eigen::VectorXd localCoefficientVector(double t) const;
/**
* Get the local coefficient vector for segment i
*
* @param segmentIdx the segment index
*
* @return The local coefficient vector active on time segment i
*/
Eigen::VectorXd segmentCoefficientVector(int segmentIdx) const;
/**
* Update the local coefficient vector
*
* @param t The time used to select the local coefficients.
* @param c The local coefficient vector.
*/
void setLocalCoefficientVector(double t, const Eigen::VectorXd & c);
/**
* Get the indices of the local coefficients active at time t.
*
* @param t The time being queried.
*
* @return The indices of the local coefficients active at time t.
*/
Eigen::VectorXi localCoefficientVectorIndices(double t) const;
/**
* Get the indices of the local coefficients active on segment i
*
* @param segmentIdx The segment being queried.
*
* @return The indices of the local coefficients active on this segment.
*/
Eigen::VectorXi segmentCoefficientVectorIndices(int segmentIdx) const;
/**
* Get the indices of the local vector-valued coefficients active at time t.
*
* @param t The time being queried.
*
* @return The indices of the local vector-valued coefficients active at time t.
*/
Eigen::VectorXi localVvCoefficientVectorIndices(double t) const;
/**
* Get the indices of the local vector-valued coefficients active on segment i
*
* @param segmentIdx The segment being queried.
*
* @return The indices of the local vector-valued coefficients active on this segment.
*/
Eigen::VectorXi segmentVvCoefficientVectorIndices(int segmentIdx) const;
int coefficientVectorLength() const;
/**
* Initialize a spline from two times and two positions. The spline will be initialized to
* have one valid time segment \f$[t_0, t_1)\f$ such that \f$\mathbf b(t_0) = \mathbf p_0\f$,
* \f$\mathbf b(t_1) = \mathbf p_1\f$,
* \f$\dot{\mathbf b}(t_0) = \frac{\mathbf{p_1} - \mathbf p_0}{t_1 - t_0}\f$, and
* \f$\dot{\mathbf b}(t_1) = \frac{\mathbf{p_1} - \mathbf p_0}{t_1 - t_0}\f$.
*
* @param t_0 The start of the time interval.
* @param t_1 The end of the time interval
* @param p_0 The position at the start of the time interval.
* @param p_1 The position at the end of the time interval.
*/
void initSpline(double t_0, double t_1, const Eigen::VectorXd & p_0, const Eigen::VectorXd & p_1);
void initSpline2(const Eigen::VectorXd & times, const Eigen::MatrixXd & interpolationPoints, int numSegments, double lambda);
void initSpline3(const Eigen::VectorXd & times, const Eigen::MatrixXd & interpolationPoints, int numSegments, double lambda);
void initSplineSparse(const Eigen::VectorXd & times, const Eigen::MatrixXd & interpolationPoints, int numSegments, double lambda);
void initSplineSparseKnots(const Eigen::VectorXd ×, const Eigen::MatrixXd &interpolationPoints, const Eigen::VectorXd knots, double lambda);
/**
* Add a curve segment that interpolates the point p, ending at time t.
*
* If the new time corresponds with the first knot past the end of the curve,
* the existing curve is perfectly preserved. Otherwise, the existing curve
* will interpolate its current position at the current endpoint and the new
* position at the new endpoint but will not necessarily match the last segment
* exactly.
*
* @param t The time of the point to interpolate. This must be greater than t_max()
* @param p The point to interpolate at time t.
*/
void addCurveSegment(double t, const Eigen::VectorXd & p);
/**
* Add a curve segment that interpolates the point p, ending at time t.
*
* If the new time corresponds with the first knot past the end of the curve,
* the existing curve is perfectly preserved. Otherwise, the existing curve
* will interpolate its current position at the current endpoint and the new
* position at the new endpoint but will not necessarily match the last segment
* exactly.
*
* @param t The time of the point to interpolate. This must be greater than t_max()
* @param p The point to interpolate at time t.
* @param lambda a smoothness parameter. Higher for more smooth.
*/
void addCurveSegment2(double t, const Eigen::VectorXd & p, double lambda);
/**
* Removes a curve segment from the left by removing one knot and one coefficient vector.
* After calling this function, the curve will have one fewer segment. The new minimum
* time will be timeInterval(0).first
*
*/
void removeCurveSegment();
/**
* Get the \f$ \mathbf V_i \f$ matrix associated with the integral over the segment.
*
* @param segmentIndex
*
* @return the \f$ \mathbf V_i \f$ matrix
*/
Eigen::MatrixXd Vi(int segmentIndex) const;
Eigen::VectorXd evalIntegral(double t1, double t2) const;
inline Eigen::VectorXd evalI(double t1, double t2) const {return evalIntegral(t1,t2);}
Eigen::MatrixXd Mi(int segmentIndex) const;
Eigen::MatrixXd Bij(int segmentIndex, int columnIndex) const;
Eigen::MatrixXd U(double t, int derivativeOrder) const;
Eigen::VectorXd u(double t, int derivativeOrder) const;
int segmentIndex(double t) const;
Eigen::MatrixXd Dii(int segmentIndex) const;
Eigen::MatrixXd Di(int segmentIndex) const;
/**
* Get the b_i(t) for i in localVvCoefficientVectorIndices (@see #localVvCoefficientVectorIndices).
*
* @param t The time being queried.
*
* @return [b_i(t) for i in localVvCoefficientVectorIndices].
*
*/
Eigen::VectorXd getLocalBiVector(double t) const;
void getLocalBiInto(double t, Eigen::VectorXd & ret) const;
/**
* Get the cumulative (tilde) b_i(t) for i in localVvCoefficientVectorIndices (@see #localVvCoefficientVectorIndices).
*
* @param t The time being queried.
*
* @return [tilde b_i(t) for i in localVvCoefficientVectorIndices].
*
*/
Eigen::VectorXd getLocalCumulativeBiVector(double t) const;
Eigen::CwiseNullaryOp <BiVector, Eigen::VectorXd> getBiVector(double t) const {
return Eigen::CwiseNullaryOp <BiVector, Eigen::VectorXd>(numValidTimeSegments(), 1, BiVector(segmentIndex(t), getLocalBiVector(t), 0));
}
Eigen::CwiseNullaryOp <BiVector, Eigen::VectorXd> getCumulativeBiVector(double t) const {
return Eigen::CwiseNullaryOp <BiVector, Eigen::VectorXd>(numValidTimeSegments(), 1, BiVector(segmentIndex(t), getLocalCumulativeBiVector(t), 1));
}
Eigen::MatrixXd segmentIntegral(int segmentIdx, const Eigen::MatrixXd& W, int derivativeOrder) const;
Eigen::MatrixXd segmentQuadraticIntegral(const Eigen::MatrixXd & W, int segmentIdx, int derivativeOrder) const;
Eigen::MatrixXd segmentQuadraticIntegralDiag(const Eigen::VectorXd & Wdiag, int segmentIdx, int derivativeOrder) const;
Eigen::MatrixXd curveQuadraticIntegral(const Eigen::MatrixXd & W, int derivativeOrder) const;
Eigen::MatrixXd curveQuadraticIntegralDiag(const Eigen::VectorXd & Wdiag, int derivativeOrder) const;
sparse_block_matrix::SparseBlockMatrix< Eigen::MatrixXd> curveQuadraticIntegralSparse(const Eigen::MatrixXd & W, int derivativeOrder) const;
sparse_block_matrix::SparseBlockMatrix<Eigen::MatrixXd> curveQuadraticIntegralDiagSparse(const Eigen::VectorXd & Wdiag, int derivativeOrder) const;
void initConstantSpline(double t_min, double t_max, int numSegments, const Eigen::VectorXd & constant);
private:
/**
* An internal function to find the segment of the knot sequence
* that the time t falls in. The function returns the
* value \f$ u = \frac{t - t_i}{t_{i+1} - t_i} \f$ and the index \f$i\f$
*
* @param t The time being queried.
*
* @return A pair with the first value \f$ u = \frac{t - t_i}{t_{i+1} - t_i} \f$ and the second value the index \f$i\f$
*/
std::pair<double,int> computeUAndTIndex(double t) const;
/**
* An internal function to find the segment of the knot sequence
* that the time t falls in. The function returns the width of the
* knot segment \f$ \Delta t_i = t_{i+1} - t_i \f$ and the index \f$i\f$
*
* @param t The time being queried.
*
* @return A pair with the first value \f$ \Delta t_i = t_{i+1} - t_i \f$ and the second value the index \f$i\f$
*/
std::pair<double,int> computeTIndex(double t) const;
/**
* Compute the vector \f$ \mathbf u(t) \f$ for a spline of
* order \f$ S \f$, this is an \f$ S \times 1 \f$ vector.
*
* At derivative order 0 (no derivative), this vector is
* \f$ \mathbf u(t) = \left [ 1 \; u(t) \; u(t)^2 \; \dots \; u(t)^{S-1} \right ]^T \f$
*
* For higher derivative order \f$ M \f$, the vector returned is
* \f$ \mathbf u^{(M)}(t) = \frac{\partial^{(M)}\mathbf u(t)}{\partial t^{(M)}}
*
* @param uval the value \f$ u(t) \f$
* @param segmentIndex
* @param derivativeOrder
*
* @return
*/
Eigen::VectorXd computeU(double uval, int segmentIndex, int derivativeOrder) const;
int basisMatrixIndexFromStartingKnotIndex(int startingKnotIndex) const;
int startingKnotIndexFromBasisMatrixIndex(int basisMatrixIndex) const;
const Eigen::MatrixXd & basisMatrixFromKnotIndex(int knotIndex) const;
/**
* Throws an exception if the knot sequence is not non-decreasing.
*
* @param knots The knot sequence to verify.
*/
void verifyKnotSequence(const std::vector<double> & knots);
/**
* Initialize the basis matrices based on the current knot sequence.
* There is one basis matrix for each valid time segment defined by the spline.
*
* Implemented using the recursive basis matrix algorithm from
* Qin, Kaihuai, General matrix representations for B-splines, The Visual Computer (2000) 16:177–186
*
*/
void initializeBasisMatrices();
/**
* The recursive function used to implement the recursive basis matrix algorithm from
* Qin, Kaihuai, General matrix representations for B-splines, The Visual Computer (2000) 16:177–186
*
* @param k The order of the matrix requested.
* @param i The time segment of the basis matrix
*
* @return
*/
Eigen::MatrixXd M(int k, int i);
/**
* A helper function for producing the M matrices. Defined in
* Qin, Kaihuai, General matrix representations for B-splines, The Visual Computer (2000) 16:177–186
*
*/
double d_0(int k, int i, int j);
/**
* A helper function for producing the M matrices. Defined in
* Qin, Kaihuai, General matrix representations for B-splines, The Visual Computer (2000) 16:177–186
*
*/
double d_1(int k, int i, int j);
/// The order of the spline.
int splineOrder_;
/// The knot sequence used by the B-spline.
std::vector<double> knots_;
/// The coefficient matrix used by the B-Spline. Each column can be seen as a
/// single vector-valued spline coefficient.
/// This is stored explicityl in column major order to ensure that each column (i.e.
/// a single vector-valued spline coefficient) is stored in contiguous memory. This
/// allows one to, for example, map a single spline coefficient using the Eigen::Map type.
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor> coefficients_;
//Eigen::MatrixXd coefficients_;
/// The basis matrices for each time segment the B-spline is defined over.
std::vector<Eigen::MatrixXd> basisMatrices_;
};
} // namespace bsplines
#endif /* _BSPLINE_HPP */