[wpilib] Fix SplineHelper cubic spline bug (#2572)

This commit is contained in:
Prateek Machiraju
2020-07-06 01:13:28 -04:00
committed by GitHub
parent 5bd2dca463
commit b3b2aa6359
2 changed files with 13 additions and 6 deletions

View File

@@ -145,8 +145,11 @@ public final class SplineHelper {
if (newWaypts.length > 4) {
for (int i = 1; i <= newWaypts.length - 4; i++) {
dx[i] = 3 * (newWaypts[i + 1].getX() - newWaypts[i - 1].getX());
dy[i] = 3 * (newWaypts[i + 1].getY() - newWaypts[i - 1].getY());
// dx and dy represent the derivatives of the internal waypoints. The derivative
// of the second internal waypoint should involve the third and first internal waypoint,
// which have indices of 1 and 3 in the newWaypts list (which contains ALL waypoints).
dx[i] = 3 * (newWaypts[i + 2].getX() - newWaypts[i].getX());
dy[i] = 3 * (newWaypts[i + 2].getY() - newWaypts[i].getY());
}
}