弹道轨迹的 3D 目标领先公式 [英] 3D Target Leading formula for a ballistic trajectory

查看:24
本文介绍了弹道轨迹的 3D 目标领先公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个目标领先公式,用于在具有弹道轨迹的 3d 目标领先,如果没有,我想知道是否可以通过对齐来将 2d 目标领先公式转换为 3d 目标领先公式它是沿着目标运动的平面吗?

I was wondering if there was a target leading formula for target leading in 3d with a ballistic trajectory and if not i was wondering if it is possible to convert a 2d target leading formula to work as a 3d target leading formula by aligning the plane it is on along the motion of the target?

推荐答案

在发射弹丸时可以很容易地计算出领先目标,但不能保证目标不会改变航向、加速或减速弹丸在空中.在任何情况下,当您领先目标时,您可以假设目标的速度将保持不变,或者如果它正在加速,则其加速度将保持不变.

Leading the target can be easily calculated at the time the projectile is fired, however there is no guarantee the target won't change course, accelerate, or decelerate while the projectile is in the air. In any case, when you're leading the target you can either assume that the target's velocity will remain the same, or if it is accelerating, that its acceleration will remain the same.

这是我写的博文关于随着时间的推移预测行驶距离,考虑加速度.这是我使用的代码.

Here's a blog post I wrote about predicting a traveled distance over time, accounting for acceleration. And here is the code I use.

这将计算在恒定加速度下随时间移动的距离.在这种情况下,constantAccel 是一个速度,如果您的目标没有加速,那么您只需使用 0.0f 作为该参数.

This will calculate a distance traveled, over time, given a constant acceleration. In this case constantAccel is a speed, and if your target isn't accelerating then you would just use 0.0f for that parameter.

float CalcDistanceOverTime(const float initVelocity, 
                           const float constantAccel,
                           const float timeDelta)
{
    return  (initVelocity * timeDelta)
          + (0.5f * constantAccel * (timeDelta * timeDelta);
}

这是一个例子:

Vector3 targetsVelocity(3.0f, 0.0f, 3.0f);
float targetsAcceleration = 1.0f;

float distanceTraveled = CalcDistanceOverTime(targetsVelocity, targetsAcceleration, timeDelta)

Vector3 finalPosition = targetsVelocity * distanceTraveled;

您可能会注意到您需要一个 timeDelta 来传递给这个公式.这意味着,根据您的射弹的轨迹和速度,您需要知道到达目标需要多长时间,但是由于您不确切知道可能需要多长时间,因此变得更加困难你知道它会在哪里.我不确定这个的确切公式,但我相信使用微积分你可以计算,基于你的射弹的速度和速度,以及你的目标的速度和速度,考虑到重力,你应该能够在空间中找到这两个可以碰撞的点.

You may notice that you'll need a timeDelta to pass to this formula. This means, based on your projectile's trajectory and speed, you'll need to know about how long it will take to reach the target, however it is made more difficult by the fact that you don't know exactly how long that may take until you know where it will be. I'm not sure of the exact formula for this, but I believe using Calculus you could calculate, based on the speed and velocity of your projectile, and the speed and velocity of your target, accounting for gravity with both, that you should be able to find a point in space where these two can collide.

如果上面的方法不可行,那么你可以选择一个固定的timeDelta,如果你能保证你的弹丸可以以你想要的任何角度和速度前进.例如,选择 3 秒作为您的 timeDelta,您知道 3 秒后目标将在哪里,并立即发射一个您知道将在 3 秒内到达该点的射弹.

If the above method isn't feasible then you may be able to choose a fixed timeDelta, if you can guarantee your projectile can go at whatever angle and speed that you would like. For example, pick 3 seconds as your timeDelta, you know where the target will be in 3 seconds, and immediately fire a projectile that you know will reach that point in space within 3 seconds.

为了以防万一,这里有一个 博文 关于在 3D 中计算弹道轨迹.用这种方法计算目标时间应该很简单,基于向外的垂直速度和位置,只需使用重力计算该位置到达目标位置的海拔需要多少秒.

And just in case, here's a blog post about calculating ballistic trajectory in 3D. Calculating the time to target with this method should be simple, based on outgoing vertical velocity and position, just use gravity to calculate how many seconds until that position reaches the elevation at the target position.

这篇关于弹道轨迹的 3D 目标领先公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆