cmvr-es/include/utils/base/abstract_interpolation.h

73 lines
2.1 KiB
C
Raw Permalink Normal View History

2025-08-28 10:50:22 +08:00
#ifndef INTERPOLATION_BASE_H
#define INTERPOLATION_BASE_H
2025-08-28 11:18:17 +08:00
#include "utils/math/geometry.h"
2025-08-28 10:50:22 +08:00
#include <vector>
#include <stdexcept>
2025-08-28 11:18:17 +08:00
namespace cmvr::math {
2025-08-28 10:50:22 +08:00
2025-08-28 11:18:17 +08:00
/**
* 姿
* 姿(Pose3d)姿(Pose2d)
*/
class AbstractInterpolation {
public:
// 构造函数
AbstractInterpolation(const std::vector<Pose3d>& waypoints);
AbstractInterpolation(const std::vector<Pose2d>& waypoints);
2025-08-28 10:50:22 +08:00
2025-08-28 11:18:17 +08:00
// 析构函数
virtual ~AbstractInterpolation() = default;
2025-08-28 10:50:22 +08:00
2025-08-28 11:18:17 +08:00
/**
*
* @param t [0, 1]01
* @return 姿
*/
virtual Pose3d interpolate_3d(double t) const = 0;
virtual Pose2d interpolate_2d(double t) const = 0;
2025-08-28 10:50:22 +08:00
2025-08-28 11:18:17 +08:00
/**
*
* @param num_points
* @return
*/
std::vector<Pose3d> generate_trajectory_3d(size_t num_points) const;
std::vector<Pose2d> generate_trajectory_2d(size_t num_points) const;
protected:
// 路径点存储
std::vector<Pose3d> waypoints_3d_;
std::vector<Pose2d> waypoints_2d_;
/**
* 线
* @param a
* @param b
* @param t [0,1]
* @return
*/
static double linear_interpolate(double a, double b, double t);
/**
* 线(slerp)
* @param q1
* @param q2
* @param t [0,1]
* @return
*/
static Quat slerp(const Quat& q1, const Quat& q2, double t);
/**
* t的范围并进行约束
* @param t
* @return [0,1]
*/
static double clamp_t(double t);
};
} // namespace cmvr::math
2025-08-28 10:50:22 +08:00
#endif // INTERPOLATION_BASE_H