#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <fstream>
// 定义常量
const double PI = 3.14159265358979323846;
// 点数据结构
struct Point {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
};
// 轨迹管理类
class Trajectory {
private:
std::vector<Point> points; // 存储轨迹点
public:
// 添加点
void addPoint(const Point& point) {
points.push_back(point);
}
// 计算两点之间的距离
static double calculateDistance(const Point& p1, const Point& p2) {
return std::sqrt(std::pow(p2.x - p1.x, 2) + std::pow(p2.y - p1.y, 2));
}
// 计算两点之间的方位角(以正北为 0 度,顺时针增加)
static double calculateAzimuth(const Point& p1, const Point& p2) {
double dx = p2.x - p1.x;
double dy = p2.y - p1.y;
// 计算初始方位角(弧度),以正东为 0 度,逆时针增加
double angle = std::atan2(dy, dx);
// 将弧度转换为度
double azimuth = angle * 180.0 / PI;
// 将数学角度转换为以正北为 0 度的方位角
azimuth = 90 - azimuth;
// 确保角度在 [0°, 360°) 范围内
if (azimuth < 0) {
azimuth += 360;
}
return azimuth;
}
// 内插点
static Point interpolatePoint(const Point& p1, const Point& p2, double t) {
double x = p1.x + t * (p2.x - p1.x);
double y = p1.y + t * (p2.y - p1.y);
return Point(x, y);
}
// 生成内插点
std::vector<Point> generateInterpolatedPoints(int numPoints) {
std::vector<Point> interpolatedPoints;
if (points.size() < 2) {
std::cerr << "至少需要两个点才能进行内插。\n";
return interpolatedPoints;
}
for (size_t i = 0; i < points.size() - 1; ++i) {
for (int j = 1; j <= numPoints; ++j) {
double t = static_cast<double>(j) / (numPoints + 1);
interpolatedPoints.push_back(interpolatePoint(points[i], points[i + 1], t));
}
}
return interpolatedPoints;
}
// 打印所有点的坐标
void printPoints() const {
for (const auto& point : poin
#include <vector>
#include <cmath>
#include <iomanip>
#include <fstream>
// 定义常量
const double PI = 3.14159265358979323846;
// 点数据结构
struct Point {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
};
// 轨迹管理类
class Trajectory {
private:
std::vector<Point> points; // 存储轨迹点
public:
// 添加点
void addPoint(const Point& point) {
points.push_back(point);
}
// 计算两点之间的距离
static double calculateDistance(const Point& p1, const Point& p2) {
return std::sqrt(std::pow(p2.x - p1.x, 2) + std::pow(p2.y - p1.y, 2));
}
// 计算两点之间的方位角(以正北为 0 度,顺时针增加)
static double calculateAzimuth(const Point& p1, const Point& p2) {
double dx = p2.x - p1.x;
double dy = p2.y - p1.y;
// 计算初始方位角(弧度),以正东为 0 度,逆时针增加
double angle = std::atan2(dy, dx);
// 将弧度转换为度
double azimuth = angle * 180.0 / PI;
// 将数学角度转换为以正北为 0 度的方位角
azimuth = 90 - azimuth;
// 确保角度在 [0°, 360°) 范围内
if (azimuth < 0) {
azimuth += 360;
}
return azimuth;
}
// 内插点
static Point interpolatePoint(const Point& p1, const Point& p2, double t) {
double x = p1.x + t * (p2.x - p1.x);
double y = p1.y + t * (p2.y - p1.y);
return Point(x, y);
}
// 生成内插点
std::vector<Point> generateInterpolatedPoints(int numPoints) {
std::vector<Point> interpolatedPoints;
if (points.size() < 2) {
std::cerr << "至少需要两个点才能进行内插。\n";
return interpolatedPoints;
}
for (size_t i = 0; i < points.size() - 1; ++i) {
for (int j = 1; j <= numPoints; ++j) {
double t = static_cast<double>(j) / (numPoints + 1);
interpolatedPoints.push_back(interpolatePoint(points[i], points[i + 1], t));
}
}
return interpolatedPoints;
}
// 打印所有点的坐标
void printPoints() const {
for (const auto& point : poin