This commit is contained in:
Jeff 2014-06-23 20:24:31 -06:00
commit f9496d341f
2 changed files with 55 additions and 55 deletions

View File

@ -76,9 +76,9 @@ namespace Eigen
**/ **/
template <typename KnotVectorType, typename ParameterVectorType> template <typename KnotVectorType, typename ParameterVectorType>
void KnotAveragingWithDerivatives(const ParameterVectorType& parameters, void KnotAveragingWithDerivatives(const ParameterVectorType& parameters,
const unsigned int degree, const unsigned int degree,
const IndexArray& derivativeIndices, const IndexArray& derivativeIndices,
KnotVectorType& knots) KnotVectorType& knots)
{ {
typedef typename ParameterVectorType::Scalar Scalar; typedef typename ParameterVectorType::Scalar Scalar;
@ -137,35 +137,35 @@ namespace Eigen
int temporaryParameterIndex = 1; int temporaryParameterIndex = 1;
for (int j = 0; j < numParameters; ++j) for (int j = 0; j < numParameters; ++j)
{ {
Scalar parameter = parameters[j]; Scalar parameter = parameters[j];
if (parameter >= averageKnots[i] && parameter < averageKnots[i + 1]) if (parameter >= averageKnots[i] && parameter < averageKnots[i + 1])
{ {
parameterIndices[temporaryParameterIndex] = j; parameterIndices[temporaryParameterIndex] = j;
temporaryParameters[temporaryParameterIndex++] = parameter; temporaryParameters[temporaryParameterIndex++] = parameter;
} }
} }
temporaryParameters[temporaryParameterIndex] = averageKnots[i + 1]; temporaryParameters[temporaryParameterIndex] = averageKnots[i + 1];
for (int j = 0; j <= temporaryParameterIndex - 2; ++j) for (int j = 0; j <= temporaryParameterIndex - 2; ++j)
{ {
for (DenseIndex k = 0; k < derivativeIndices.size(); ++k) for (DenseIndex k = 0; k < derivativeIndices.size(); ++k)
{ {
if (parameterIndices[j + 1] == derivativeIndices[k] if (parameterIndices[j + 1] == derivativeIndices[k]
&& parameterIndices[j + 1] != 0 && parameterIndices[j + 1] != 0
&& parameterIndices[j + 1] != numParameters - 1) && parameterIndices[j + 1] != numParameters - 1)
{ {
derivativeKnots[++newKnotIndex] = temporaryParameters.segment(j, 3).mean(); derivativeKnots[++newKnotIndex] = temporaryParameters.segment(j, 3).mean();
break; break;
} }
} }
} }
} }
KnotVectorType temporaryKnots(averageKnots.size() + derivativeKnots.size()); KnotVectorType temporaryKnots(averageKnots.size() + derivativeKnots.size());
std::merge(averageKnots.data(), averageKnots.data() + averageKnots.size(), std::merge(averageKnots.data(), averageKnots.data() + averageKnots.size(),
derivativeKnots.data(), derivativeKnots.data() + derivativeKnots.size(), derivativeKnots.data(), derivativeKnots.data() + derivativeKnots.size(),
temporaryKnots.data()); temporaryKnots.data());
// Number of control points (one for each point and derivative) plus spline order. // Number of control points (one for each point and derivative) plus spline order.
DenseIndex numKnots = numParameters + numDerivatives + degree + 1; DenseIndex numKnots = numParameters + numDerivatives + degree + 1;
@ -257,9 +257,9 @@ namespace Eigen
**/ **/
template <typename PointArrayType> template <typename PointArrayType>
static SplineType InterpolateWithDerivatives(const PointArrayType& points, static SplineType InterpolateWithDerivatives(const PointArrayType& points,
const PointArrayType& derivatives, const PointArrayType& derivatives,
const IndexArray& derivativeIndices, const IndexArray& derivativeIndices,
const unsigned int degree); const unsigned int degree);
/** /**
* \brief Fits an interpolating spline to the given data points and derivatives. * \brief Fits an interpolating spline to the given data points and derivatives.
@ -279,10 +279,10 @@ namespace Eigen
*/ */
template <typename PointArrayType> template <typename PointArrayType>
static SplineType InterpolateWithDerivatives(const PointArrayType& points, static SplineType InterpolateWithDerivatives(const PointArrayType& points,
const PointArrayType& derivatives, const PointArrayType& derivatives,
const IndexArray& derivativeIndices, const IndexArray& derivativeIndices,
const unsigned int degree, const unsigned int degree,
const ParameterVectorType& parameters); const ParameterVectorType& parameters);
}; };
template <typename SplineType> template <typename SplineType>
@ -330,10 +330,10 @@ namespace Eigen
template <typename PointArrayType> template <typename PointArrayType>
SplineType SplineType
SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points, SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points,
const PointArrayType& derivatives, const PointArrayType& derivatives,
const IndexArray& derivativeIndices, const IndexArray& derivativeIndices,
const unsigned int degree, const unsigned int degree,
const ParameterVectorType& parameters) const ParameterVectorType& parameters)
{ {
typedef typename SplineType::KnotVectorType::Scalar Scalar; typedef typename SplineType::KnotVectorType::Scalar Scalar;
typedef typename SplineType::ControlPointVectorType ControlPointVectorType; typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
@ -387,16 +387,16 @@ namespace Eigen
if (derivativeIndices[derivativeIndex] == i) if (derivativeIndices[derivativeIndex] == i)
{ {
A.block(row, span - degree, 2, degree + 1) A.block(row, span - degree, 2, degree + 1)
= SplineType::BasisFunctionDerivatives(parameters[i], 1, degree, knots); = SplineType::BasisFunctionDerivatives(parameters[i], 1, degree, knots);
b.col(row++) = points.col(i); b.col(row++) = points.col(i);
b.col(row++) = derivatives.col(derivativeIndex++); b.col(row++) = derivatives.col(derivativeIndex++);
} }
else else
{ {
A.row(row++).segment(span - degree, degree + 1) A.row(row++).segment(span - degree, degree + 1)
= SplineType::BasisFunctions(parameters[i], degree, knots); = SplineType::BasisFunctions(parameters[i], degree, knots);
} }
} }
b.col(0) = points.col(0); b.col(0) = points.col(0);
@ -417,9 +417,9 @@ namespace Eigen
template <typename PointArrayType> template <typename PointArrayType>
SplineType SplineType
SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points, SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points,
const PointArrayType& derivatives, const PointArrayType& derivatives,
const IndexArray& derivativeIndices, const IndexArray& derivativeIndices,
const unsigned int degree) const unsigned int degree)
{ {
ParameterVectorType parameters; ParameterVectorType parameters;
ChordLengths(points, parameters); ChordLengths(points, parameters);

View File

@ -13,23 +13,23 @@
namespace Eigen { namespace Eigen {
// lets do some explicit instantiations and thus // lets do some explicit instantiations and thus
// force the compilation of all spline functions... // force the compilation of all spline functions...
template class Spline<double, 2, Dynamic>; template class Spline<double, 2, Dynamic>;
template class Spline<double, 3, Dynamic>; template class Spline<double, 3, Dynamic>;
template class Spline<double, 2, 2>; template class Spline<double, 2, 2>;
template class Spline<double, 2, 3>; template class Spline<double, 2, 3>;
template class Spline<double, 2, 4>; template class Spline<double, 2, 4>;
template class Spline<double, 2, 5>; template class Spline<double, 2, 5>;
template class Spline<float, 2, Dynamic>; template class Spline<float, 2, Dynamic>;
template class Spline<float, 3, Dynamic>; template class Spline<float, 3, Dynamic>;
template class Spline<float, 3, 2>; template class Spline<float, 3, 2>;
template class Spline<float, 3, 3>; template class Spline<float, 3, 3>;
template class Spline<float, 3, 4>; template class Spline<float, 3, 4>;
template class Spline<float, 3, 5>; template class Spline<float, 3, 5>;
} }