#include #include <math.h>

using namespace std;

int main() { int t = 0; // 计时器 double x, y; // 飞机当前位置 double v = 10.0; // 飞机速度 double R = 50.0; // 8 字形半径 double w = 0.5; // 角速度 double theta = 0.0; // 当前角度

while (t < 200)  // 总共飞行 200 个单位时间
{
    // 计算当前位置
    x = R * cos(theta);
    y = R * sin(theta);

    // 输出当前位置
    cout << 't=' << t << ': (' << x << ',' << y << ')' << endl;

    // 更新角度
    theta += w;

    if (theta >= 2 * M_PI)  // 角度超过 360 度,重新开始
    {
        theta -= 2 * M_PI;
    }

    t++;  // 计时器加 1
}

return 0;

}

C++ 代码实现飞机 8 字形机动

原文地址: https://www.cveoy.top/t/topic/nESS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录