Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.


插值是图形编程中一个非常基本的操作. 作为一名图形开发人员, 熟悉它有助于扩展你的视野.

基本思想是从 A 转换到 B。t 值是介于两者之间的状态。

For example, if t is 0, then the state is A. If t is 1, then the state is B. Anything in-between is an interpolation.

Between two real (floating-point) numbers, an interpolation can be described as:

interpolation = A * (1 - t) + B * t


interpolation = A + (B - A) * t

The name of this type of interpolation, which transforms a value into another at constant speed is "linear". So, when you hear about Linear Interpolation, you know they are referring to this formula.

还有其他类型的插值, 这里将不做讨论. 建议之后阅读 Bezier 页面.


Vector types (Vector2 and Vector3) can also be interpolated, they come with handy functions to do it Vector2.lerp() and Vector3.lerp().

对于三次插值,还有 Vector2.cubic_interpolate()Vector3.cubic_interpolate() ,它们执行 Bezier 式插值。

Here is example pseudo-code for going from point A to B using interpolation: