对于弹道3D目标引领公式弹道、公式、目标

2023-09-08 00:53:23 作者:我恋小黄人

我在想,如果有领先的公式目标引领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.

下面是一个博客文章我写了predicting行驶距离随着时间的推移,占加速。这里是code我用。

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.0为参数。

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.

和以防万一,这里有一个的博客文章有关计算弹道轨迹的三维。计算目标使用这种方法的时候应该是简单的,基于即将离任的垂直速度和位置,只是利用重力来计算有多少秒,直到那个位置到达海拔在目标位置。

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.