@@ -147,6 +147,13 @@ public Point2D getDerivative(double t, int n) {
147147 return splines .get (index ).getDerivative (getSplineTFromT (t , index ), n );
148148 }
149149
150+ /**
151+ * Returns the closest associated t value on the spline from a {@link Point2D} using Newton's method on the distance function
152+ * @param point the {@link Point2D} that to get closest point from
153+ * @param steps the number of steps to start Newton's method from
154+ * @param iterations the number of iterations to run Newton's method on a single step
155+ * @return the closest associated t value on the spline from a {@link Point2D} using Newton's method on the distance function
156+ */
150157 @ Override
151158 public double findClosestPointOnSpline (Point2D point , int steps , int iterations ) {
152159 Vector2D cur_min = new Vector2D (Double .POSITIVE_INFINITY , 0 );
@@ -186,6 +193,11 @@ public double getGaussianQuadratureLength(double start, double end, int steps) {
186193 return length ;
187194 }
188195
196+ /**
197+ * Returns the t parameter associated with a certain length from the beginning
198+ * @param length length to get the t parameter of
199+ * @return the t parameter associated with a certain length from the beginning
200+ */
189201 @ Override
190202 public double getTFromLength (double length ) {
191203 double t = 0 ;
@@ -202,11 +214,30 @@ public double getTFromLength(double length) {
202214 return t ;
203215 }
204216
217+ /**
218+ * Returns the index of the spline closest to a {@link Point2D}
219+ * @param point {@link Point2D} to get closest spline to
220+ * @param newtonsSteps the number of steps to start Newton's method from
221+ * @return the index of the spline closest to a {@link Point2D}
222+ */
205223 public int getIndexOfSplineFromPoint (Point2D point , int newtonsSteps ) {
206224 return getSplineFromT (findClosestPointOnSpline (point , newtonsSteps , 5 ));
207225 }
208226
209- public double getIndexOfSplineFromPointI (Point2D point , int newtonsSteps ) {
210- return findClosestPointOnSpline (point , newtonsSteps , 5 );
227+ /**
228+ * Return a new {@link QuinticHermiteSplineGroup} path to this spline group's setpoint from a position, velocity, and acceleration
229+ * @param newPos {@link Pose2D} to start from
230+ * @param newVel {@link Vector2D} velocity to start from
231+ * @param newAcc {@link Vector2D} acceleration to start from
232+ * @return a new {@link QuinticHermiteSplineGroup} path to this spline group's setpoint from a position, velocity, and acceleration
233+ */
234+ @ Override
235+ public QuinticHermiteSplineGroup getNewPath (Pose2D newPos , Vector2D newVel , Vector2D newAcc ) {
236+ int index = getIndexOfSplineFromPoint (newPos .getPosition (), 100 );
237+ QuinticHermiteSplineGroup group = new QuinticHermiteSplineGroup (new QuinticHermiteSpline (newPos , splines .get (index ).getPose1 ()));
238+ for (int i = index + 1 ; i < splines .size (); i ++) {
239+ group .addSpline (splines .get (i ));
240+ }
241+ return group ;
211242 }
212243}
0 commit comments