【问题标题】:How to calculate pitch angle between two 3d vectors如何计算两个 3d 向量之间的俯仰角
【发布时间】:2021-01-20 13:44:50
【问题描述】:

我正在我的 spacesim 游戏中制作一个 AI,并尝试在敌人的方向矢量和指向某个目标的方向之间进行俯仰和偏航。以下是向目标移动的方法:

private void moveTo(Vecf target) {
    if (target == null)
        return;
    Vecf dir = getForward();
    Vecf dirToTarget = Vecf.sub(target, pos).normalize();
    float dYaw = getYaw(dir, dirToTarget);
    float dPitch = getPitch(dir, dirToTarget);
    rotate(dPitch, dYaw);
    moveForward();
}

我已经编写了getYaw(Vecf v1, Vecf v2) 方法,但我不知道如何处理音高。有人可以帮我弄这个吗?顺便说一句,角度以弧度为单位。

【问题讨论】:

    标签: java math trigonometry


    【解决方案1】:

    你需要前向和向上向量来计算俯仰和偏航

    【讨论】:

    • AI 类有正向和向上向量,但我应该如何处理它们
    猜你喜欢
    • 1970-01-01
    • 2017-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-20
    相关资源
    最近更新 更多