クランプ (clamp)
値を 0.0
~ 1.0
の範囲に制限する。
import numpy as np
def clamp(t):
return np.clip(t, 0.0, 1.0)
Code language: Python (python)
ドキュメント:
numpy.clip | NumPy Manual [Official]
参考:
clip – NumPy 配列 ndarray を任意の最小値/最大値に収める | note.nkmk.me
Best approach to create an saturating integer? – Stack Overflow
線形補間 (lerp)
def lerp(a, b, t):
return (b - a) * t + a
Code language: Python (python)
コード:
lerp, inverse lerp and remap (laundmo) – GitHub Gist
参考:
linear interpolation using pycuda – Stack Overflow
floating point linear interpolation – Stack Overflow
Simplest Example of Linear Interpolation for Color – Stack Overflow
How to interpolate 2D points between two timesteps? – Stack Overflow