lerp
#線形補間 #数学
lerpは、数値ふたつ a ・ b の間を t で線形補間する関数
またの名を mix とも(GLSL語)
$ {\rm lerp} (a, b, t) = a + (b - a) t
code:js
function lerp(a, b, t) {
return a + (b - a) * t;
}
t が [0, 1] でクランプされる派閥もあるらしい
Unityでは Mathf.Lerp 🔗 と Mathf.LerpUnclamped 🔗 の2つがある
登場作品
GLSL, Metal Shading Language, WGSL: mix(x, y, a) https://registry.khronos.org/OpenGL-Refpages/gl4/html/mix.xhtml https://www.w3.org/TR/WGSL/#mix-builtin
HLSL: lerp(x, y, s) https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-lerp
Processing: lerp(start, stop, amt) https://processing.org/reference/lerp_.html
Unity: Mathf.LerpUnclamped(a, b, t) https://docs.unity3d.com/ja/2021.2/ScriptReference/Mathf.Lerp.html
C++: std::lerp(a, b, t) https://cpprefjp.github.io/reference/cmath/lerp.html