Skip to content

Commit 4ba53a8

Browse files
committed
fixed spline group length/get t
1 parent 8e06eb2 commit 4ba53a8

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/main/java/com/github/mittyrobotics/pathfollowing/QuinticHermiteSplineGroup.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,29 @@ public double findClosestPointOnSpline(Point2D point, int steps, int iterations)
162162

163163
}
164164

165-
// /**
166-
// * Returns the Gaussian quadrature length of the parametric from a start to end t parameter
167-
// * @param start t parameter to start length calculation
168-
// * @param end t parameter to end length calculation
169-
// * @param steps number of steps (degree) of quadrature
170-
// * @return the Gaussian quadrature length of the parametric from a start to end t parameter
171-
// */
172-
// public double getGaussianQuadratureLength(double start, double end, int steps) {
173-
//
174-
// }
165+
/**
166+
* Returns the Gaussian quadrature length of the parametric from a start to end t parameter
167+
* @param start t parameter to start length calculation
168+
* @param end t parameter to end length calculation
169+
* @param steps number of steps (degree) of quadrature
170+
* @return the Gaussian quadrature length of the parametric from a start to end t parameter
171+
*/
172+
public double getGaussianQuadratureLength(double start, double end, int steps) {
173+
double length = 0;
174+
int startSpline = getSplineFromT(start);
175+
int endSpline = getSplineFromT(end);
176+
if(startSpline == endSpline) {
177+
length += splines.get(startSpline).getGaussianQuadratureLength(getSplineTFromT(start, startSpline),
178+
getSplineTFromT(end, endSpline), steps);
179+
} else {
180+
length += splines.get(startSpline).getGaussianQuadratureLength(getSplineTFromT(start, startSpline), 1, steps);
181+
length += splines.get(endSpline).getGaussianQuadratureLength(0, getSplineTFromT(end, endSpline), steps);
182+
}
183+
for (int i = startSpline + 1; i < endSpline; i++) {
184+
length += splines.get(i).getLength();
185+
}
186+
return length;
187+
}
175188

176189
@Override
177190
public double getTFromLength(double length) {

0 commit comments

Comments
 (0)