Eigen::SplineFitting< SplineType > Struct Template Reference

Spline fitting methods. More...

#include <SplineFitting.h>

Public Types

typedef SplineType::KnotVectorType KnotVectorType
 
typedef SplineType::ParameterVectorType ParameterVectorType
 

Static Public Member Functions

template<typename PointArrayType >
static SplineType Interpolate (const PointArrayType &pts, DenseIndex degree)
 Fits an interpolating Spline to the given data points. More...
 
template<typename PointArrayType >
static SplineType Interpolate (const PointArrayType &pts, DenseIndex degree, const KnotVectorType &knot_parameters)
 Fits an interpolating Spline to the given data points. More...
 
template<typename PointArrayType , typename IndexArray >
static SplineType InterpolateWithDerivatives (const PointArrayType &points, const PointArrayType &derivatives, const IndexArray &derivativeIndices, const unsigned int degree)
 Fits an interpolating spline to the given data points and derivatives. More...
 
template<typename PointArrayType , typename IndexArray >
static SplineType InterpolateWithDerivatives (const PointArrayType &points, const PointArrayType &derivatives, const IndexArray &derivativeIndices, const unsigned int degree, const ParameterVectorType &parameters)
 Fits an interpolating spline to the given data points and derivatives. More...
 

Detailed Description

template<typename SplineType>
struct Eigen::SplineFitting< SplineType >

Spline fitting methods.

Member Typedef Documentation

◆ KnotVectorType

template<typename SplineType >
typedef SplineType::KnotVectorType Eigen::SplineFitting< SplineType >::KnotVectorType

◆ ParameterVectorType

template<typename SplineType >
typedef SplineType::ParameterVectorType Eigen::SplineFitting< SplineType >::ParameterVectorType

Member Function Documentation

◆ Interpolate() [1/2]

template<typename SplineType >
template<typename PointArrayType >
SplineType Eigen::SplineFitting< SplineType >::Interpolate ( const PointArrayType &  pts,
DenseIndex  degree 
)
static

Fits an interpolating Spline to the given data points.

Parameters
ptsThe points for which an interpolating spline will be computed.
degreeThe degree of the interpolating spline.
Returns
A spline interpolating the initially provided points.
298  {
299  KnotVectorType chord_lengths; // knot parameters
300  ChordLengths(pts, chord_lengths);
301  return Interpolate(pts, degree, chord_lengths);
302 }
void ChordLengths(const PointArrayType &pts, KnotVectorType &chord_lengths)
Computes chord length parameters which are required for spline interpolation.
Definition: SplineFitting.h:171
const Mdouble degree
Definition: ExtendedMath.h:32
SplineType::KnotVectorType KnotVectorType
Definition: SplineFitting.h:196
static SplineType Interpolate(const PointArrayType &pts, DenseIndex degree)
Fits an interpolating Spline to the given data points.
Definition: SplineFitting.h:298

References Eigen::ChordLengths(), and constants::degree.

◆ Interpolate() [2/2]

template<typename SplineType >
template<typename PointArrayType >
SplineType Eigen::SplineFitting< SplineType >::Interpolate ( const PointArrayType &  pts,
DenseIndex  degree,
const KnotVectorType knot_parameters 
)
static

Fits an interpolating Spline to the given data points.

Parameters
ptsThe points for which an interpolating spline will be computed.
degreeThe degree of the interpolating spline.
knot_parametersThe knot parameters for the interpolation.
Returns
A spline interpolating the initially provided points.
268  {
270  typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
271 
272  typedef Matrix<Scalar, Dynamic, Dynamic> MatrixType;
273 
274  KnotVectorType knots;
275  KnotAveraging(knot_parameters, degree, knots);
276 
277  DenseIndex n = pts.cols();
279  for (DenseIndex i = 1; i < n - 1; ++i) {
280  const DenseIndex span = SplineType::Span(knot_parameters[i], degree, knots);
281 
282  // The segment call should somehow be told the spline order at compile time.
283  A.row(i).segment(span - degree, degree + 1) = SplineType::BasisFunctions(knot_parameters[i], degree, knots);
284  }
285  A(0, 0) = 1.0;
286  A(n - 1, n - 1) = 1.0;
287 
288  HouseholderQR<MatrixType> qr(A);
289 
290  // Here, we are creating a temporary due to an Eigen issue.
291  ControlPointVectorType ctrls = qr.solve(MatrixType(pts.transpose())).transpose();
292 
293  return SplineType(knots, ctrls);
294 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
HouseholderQR< MatrixXf > qr(A)
SCALAR Scalar
Definition: bench_gemm.cpp:45
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
void KnotAveraging(const KnotVectorType &parameters, DenseIndex degree, KnotVectorType &knots)
Computes knot averages.
Definition: SplineFitting.h:47
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:75
double Zero
Definition: pseudosolid_node_update_elements.cc:35

References constants::degree, i, Eigen::KnotAveraging(), n, qr(), and oomph::PseudoSolidHelper::Zero.

◆ InterpolateWithDerivatives() [1/2]

template<typename SplineType >
template<typename PointArrayType , typename IndexArray >
SplineType Eigen::SplineFitting< SplineType >::InterpolateWithDerivatives ( const PointArrayType &  points,
const PointArrayType &  derivatives,
const IndexArray &  derivativeIndices,
const unsigned int  degree 
)
static

Fits an interpolating spline to the given data points and derivatives.

Parameters
pointsThe points for which an interpolating spline will be computed.
derivativesThe desired derivatives of the interpolating spline at interpolation points.
derivativeIndicesAn array indicating which point each derivative belongs to. This must be the same size as derivatives.
degreeThe degree of the interpolating spline.
Returns
A spline interpolating points with derivatives at those points.
See also
Les A. Piegl, Khairan Rajab, Volha Smarodzinana. 2008. Curve interpolation with directional constraints for engineering design. Engineering with Computers
386  {
387  ParameterVectorType parameters;
388  ChordLengths(points, parameters);
389  return InterpolateWithDerivatives(points, derivatives, derivativeIndices, degree, parameters);
390 }
static SplineType InterpolateWithDerivatives(const PointArrayType &points, const PointArrayType &derivatives, const IndexArray &derivativeIndices, const unsigned int degree)
Fits an interpolating spline to the given data points and derivatives.
Definition: SplineFitting.h:383
SplineType::ParameterVectorType ParameterVectorType
Definition: SplineFitting.h:197

References Eigen::ChordLengths(), and constants::degree.

◆ InterpolateWithDerivatives() [2/2]

template<typename SplineType >
template<typename PointArrayType , typename IndexArray >
SplineType Eigen::SplineFitting< SplineType >::InterpolateWithDerivatives ( const PointArrayType &  points,
const PointArrayType &  derivatives,
const IndexArray &  derivativeIndices,
const unsigned int  degree,
const ParameterVectorType parameters 
)
static

Fits an interpolating spline to the given data points and derivatives.

Parameters
pointsThe points for which an interpolating spline will be computed.
derivativesThe desired derivatives of the interpolating spline at interpolation points.
derivativeIndicesAn array indicating which point each derivative belongs to. This must be the same size as derivatives.
degreeThe degree of the interpolating spline.
parametersThe parameters corresponding to the interpolation points.
Returns
A spline interpolating points with derivatives at those points.
See also
Les A. Piegl, Khairan Rajab, Volha Smarodzinana. 2008. Curve interpolation with directional constraints for engineering design. Engineering with Computers
310  {
312  typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
313 
314  typedef Matrix<Scalar, Dynamic, Dynamic> MatrixType;
315 
316  const DenseIndex n = points.cols() + derivatives.cols();
317 
318  KnotVectorType knots;
319 
320  KnotAveragingWithDerivatives(parameters, degree, derivativeIndices, knots);
321 
322  // fill matrix
324 
325  // Use these dimensions for quicker populating, then transpose for solving.
326  MatrixType b(points.rows(), n);
327 
328  DenseIndex startRow;
329  DenseIndex derivativeStart;
330 
331  // End derivatives.
332  if (derivativeIndices[0] == 0) {
333  A.template block<1, 2>(1, 0) << -1, 1;
334 
335  Scalar y = (knots(degree + 1) - knots(0)) / degree;
336  b.col(1) = y * derivatives.col(0);
337 
338  startRow = 2;
339  derivativeStart = 1;
340  } else {
341  startRow = 1;
342  derivativeStart = 0;
343  }
344  if (derivativeIndices[derivatives.cols() - 1] == points.cols() - 1) {
345  A.template block<1, 2>(n - 2, n - 2) << -1, 1;
346 
347  Scalar y = (knots(knots.size() - 1) - knots(knots.size() - (degree + 2))) / degree;
348  b.col(b.cols() - 2) = y * derivatives.col(derivatives.cols() - 1);
349  }
350 
351  DenseIndex row = startRow;
352  DenseIndex derivativeIndex = derivativeStart;
353  for (DenseIndex i = 1; i < parameters.size() - 1; ++i) {
354  const DenseIndex span = SplineType::Span(parameters[i], degree, knots);
355 
356  if (derivativeIndex < derivativeIndices.size() && derivativeIndices[derivativeIndex] == i) {
357  A.block(row, span - degree, 2, degree + 1) =
358  SplineType::BasisFunctionDerivatives(parameters[i], 1, degree, knots);
359 
360  b.col(row++) = points.col(i);
361  b.col(row++) = derivatives.col(derivativeIndex++);
362  } else {
363  A.row(row).segment(span - degree, degree + 1) = SplineType::BasisFunctions(parameters[i], degree, knots);
364  b.col(row++) = points.col(i);
365  }
366  }
367  b.col(0) = points.col(0);
368  b.col(b.cols() - 1) = points.col(points.cols() - 1);
369  A(0, 0) = 1;
370  A(n - 1, n - 1) = 1;
371 
372  // Solve
373  FullPivLU<MatrixType> lu(A);
374  ControlPointVectorType controlPoints = lu.solve(MatrixType(b.transpose())).transpose();
375 
376  SplineType spline(knots, controlPoints);
377 
378  return spline;
379 }
m row(1)
Scalar * b
Definition: benchVecAdd.cpp:17
cout<< "Here is the matrix m:"<< endl<< m<< endl;Eigen::FullPivLU< Matrix5x3 > lu(m)
void KnotAveragingWithDerivatives(const ParameterVectorType &parameters, const unsigned int degree, const IndexArray &derivativeIndices, KnotVectorType &knots)
Computes knot averages when derivative constraints are present. Note that this is a technical interpr...
Definition: SplineFitting.h:78
Scalar * y
Definition: level1_cplx_impl.h:128

References b, constants::degree, i, Eigen::KnotAveragingWithDerivatives(), lu(), n, row(), y, and oomph::PseudoSolidHelper::Zero.


The documentation for this struct was generated from the following file: