a
and b
with an handle
using self
as weightassert 0.00.qerp(0.0, 32.0, 128.0) == 0.0
assert 0.25.qerp(0.0, 32.0, 128.0) == 20.0
assert 0.50.qerp(0.0, 32.0, 128.0) == 48.0
assert 0.75.qerp(0.0, 32.0, 128.0) == 84.0
assert 1.00.qerp(0.0, 32.0, 128.0) == 128.0
# Quadratic Bézier interpolation between `a` and `b` with an `handle` using `self` as weight
#
# ~~~
# assert 0.00.qerp(0.0, 32.0, 128.0) == 0.0
# assert 0.25.qerp(0.0, 32.0, 128.0) == 20.0
# assert 0.50.qerp(0.0, 32.0, 128.0) == 48.0
# assert 0.75.qerp(0.0, 32.0, 128.0) == 84.0
# assert 1.00.qerp(0.0, 32.0, 128.0) == 128.0
# ~~~
fun qerp(a, handle, b: Float): Float do
var p = self
var i = 1.0 - p
var r = i*i * a +
2.0*i*p * handle +
p*p * b
return r
end
lib/core/math.nit:347,2--363,4