Fix bug in cubic and quintic hermetic spline generation (#2139)

Add documentation for spline derivatives and explicitly zero matrices.
This commit is contained in:
Matt
2019-12-01 21:29:52 -08:00
committed by Peter Johnson
parent e37ecd33ae
commit 6c8f6cf479
6 changed files with 54 additions and 11 deletions

View File

@@ -27,10 +27,19 @@ QuinticHermiteSpline::QuinticHermiteSpline(
// Populate Row 2 and Row 3 with the derivatives of the equations above.
// Then populate row 4 and 5 with the second derivatives.
for (int i = 0; i < 6; i++) {
// Here, we are multiplying by (5 - i) to manually take the derivative. The
// power of the term in index 0 is 5, index 1 is 4 and so on. To find the
// coefficient of the derivative, we can use the power rule and multiply
// the existing coefficient by its power.
m_coefficients.template block<2, 1>(2, i) =
m_coefficients.template block<2, 1>(0, i) * (5 - i);
}
for (int i = 0; i < 5; i++) {
// Here, we are multiplying by (4 - i) to manually take the derivative. The
// power of the term in index 0 is 4, index 1 is 3 and so on. To find the
// coefficient of the derivative, we can use the power rule and multiply
// the existing coefficient by its power.
m_coefficients.template block<2, 1>(4, i) =
m_coefficients.template block<2, 1>(2, i) * (5 - i);
m_coefficients.template block<2, 1>(2, i) * (4 - i);
}
}