考虑加速度的插值

时间:2013-06-25 08:53:17

标签: math physics

我真的不知道我想要做什么被认为是插值,但我会尝试解释。

现在,当我想要从A点到点B(为简单起见,只考虑1个坐标空间)时间T我使用线性插值公式计算位置:

P(t) = A + (B-A) * (t / T), T != 0

这在大多数情况下都可以正常工作,但是我想要像这样的cosider加速和制动:

  • x%速度加速到vi速度
  • 的第一个v时间
  • 下一个y%时间v速度
  • z%
  • 的最后vf时间减速达到t = T速度

考虑加速和制动,如何在P(t)中计算t[0, T]

1 个答案:

答案 0 :(得分:3)

考虑到我们有以下几点:

t0 = 0 is the beginning of the movement
ta is the point when acceleration ends
td is the point when decceleration begins
T is the end of the movement

然后我们有三个运动部分。 [t0, ta], (ta, td], (td, T]。每个都可以单独指定。对于加速/减速,我们需要计算加速度aa和减速度ad,如下所示:

aa = (v - vi) / (ta - t0)
ad = (vf - v) / (T - td)

根据您的问题,所有值均已给出。

然后运动可以表示为:

P(t) :=
    if(t < ta)
        1 / 2 * aa * t^2 + vi * t + A
    else if(t < td)
        v * (t - ta) + 1 / 2 * aa * ta^2 + vi * ta + A
                    // this is the length of the first part
    else
        1 / 2 * ad * (t - td)^2 + v * (t - td) 
          + v * (td - ta) + 1 / 2 * aa * ta^2 + vi * ta + A
          //those are the lengths of the first two parts

如果我们预先计算零件的长度

s1 := 1 / 2 * aa * ta^2 + vi * ta + A
s2 := v * (td - ta)

然后公式变得更短:

P(t) :=
    if(t < ta)
        1 / 2 * aa * t^2 + vi * t + A
    else if(t < td)
        v * (t - ta) + s1
    else
        1 / 2 * ad * (t - td)^2 + v * (t - td) + s1 + s2

以下是一个示例图:

Example

但是,除非您选择了正确的值,否则移动很可能不会B T。那是因为方程式过度指定。你可以,例如根据B计算v而不是指定它。

修改

计算v以达到特定B为:

v = (2 * A - 2 * B - td * vf + T * vf + ta * vi) / (ta - td - T)