mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilib] Fix SplineHelper cubic spline bug (#2572)
This commit is contained in:
committed by
GitHub
parent
5bd2dca463
commit
b3b2aa6359
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user