diff --git a/gtsam/basis/Chebyshev2.h b/gtsam/basis/Chebyshev2.h index 55bb39488..4c3542d56 100644 --- a/gtsam/basis/Chebyshev2.h +++ b/gtsam/basis/Chebyshev2.h @@ -51,30 +51,27 @@ class GTSAM_EXPORT Chebyshev2 : public Basis { using Parameters = Eigen::Matrix; using DiffMatrix = Eigen::Matrix; - /** - * @brief Specific Chebyshev point, within [a,b] interval. - * Default interval is [-1, 1] - * - * @param N The degree of the polynomial - * @param j The index of the Chebyshev point - * @param a Lower bound of interval (default: -1) - * @param b Upper bound of interval (default: 1) - * @return double - */ - static double Point(size_t N, int j, double a = -1, double b = 1) { + /// Specific Chebyshev point + static double Point(size_t N, int j) { assert(j >= 0 && size_t(j) < N); const double dtheta = M_PI / (N > 1 ? (N - 1) : 1); // We add -PI so that we get values ordered from -1 to +1 - // sin(-M_PI_2 + dtheta*j); also works + // sin(- M_PI_2 + dtheta*j); also works + return cos(-M_PI + dtheta * j); + } + + /// Specific Chebyshev point, within [a,b] interval + static double Point(size_t N, int j, double a, double b) { + assert(j >= 0 && size_t(j) < N); + const double dtheta = M_PI / (N - 1); + // We add -PI so that we get values ordered from -1 to +1 return a + (b - a) * (1. + cos(-M_PI + dtheta * j)) / 2; } /// All Chebyshev points static Vector Points(size_t N) { Vector points(N); - for (size_t j = 0; j < N; j++) { - points(j) = Point(N, j); - } + for (size_t j = 0; j < N; j++) points(j) = Point(N, j); return points; }