“线性插值"是什么意思意思? [英] What does "linear interpolation" mean?

查看:46
本文介绍了“线性插值"是什么意思意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常在 WPF 中的动画上下文中听到术语线性插值".线性插值"究竟是什么意思?你能给我举个例子,在哪里使用线性插值"?

I often hear the term "linear interpolation" in context with animations in WPF. What exactly does "linear interpolation" mean? Could you give me an example where to use "linear interpolation"?

推荐答案

Linear 表示线条(直线).

Linear means lines (straight ones).

插值是在其他两个点找到一个点的行为.将此与外推法进行对比,外推法是寻找超出线端的点.

Interpolation is the act of finding a point within two other points. Contrast this with extrapolation, which is finding a point beyond the ends of a line.

所以线性插值就是使用一条直线来找到两个其他点之间的点.

So linear interpolation is the use of a straight line to find a point between two others.

例如:

     *(5,10)
    /
   /
  /
 /
*(0,0)

您可以使用线性插值的两个端点来获取沿线的点:

You can use the two endpoints with linear interpolation to get the points along the line:

(1,2)
(2,4)
(3,6)
(4,8)

和线性外推得到(例如):

(1000,2000)
(-1e27,-2e27)

<小时>

在动画中,假设您有一个弹跳球,它从 (60,22)(x,y) 位置移动到 (198,12)10 秒内.


In animation, let's say you have a bouncing ball that travels from the (x,y) position of (60,22) to (198,12) in 10 seconds.

动画速率为每秒 10 帧,您可以随时计算其位置:

With an animation rate of 10 frames per second, you can calculate it's position at any time with:

x0 = 60, y0 = 22
x1 = 198, y1 = 12
frames = 100
for t = 0 to frames:
    x = (x1 - x0) * (t / frames) + x0
    y = (y1 - y0) * (t / frames) + y0

底部的那两个公式是线性插值的示例.在 50%(其中 t == 50):

Those two formulae at the bottom are examples of linear interpolation. At 50% (where t == 50):

x = (198 - 60) * (50 / 100) + 60
  =     138    *    0.5     + 60
  =            69           + 60
  =                  129

y = (12 - 22) * (50 / 100) + 22
  =    -10    *    0.5     + 22
  =           -5           + 22
  =                   17

(129,17) 是起始位置和结束位置之间的中点.

and (129,17) is the midpoint between the starting and ending positions.

这篇关于“线性插值"是什么意思意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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