interpolation-bezier-quadratic

quadratic bezier interpolation
Author: toneburst
License: BSD
Github: toneburst/math/interpolation bezier quadratic.axo

Inlets

frac32.positive input value

Outlets

frac32.positive interpolated output

Parameters

frac32.u.map curve

Declaration
__attribute__((always_inline)) __STATIC_INLINE float int2f(int32_t val) {
  return val * (float)(1.0f / (1 << 27));
}

__attribute__((always_inline)) __STATIC_INLINE int32_t f2int(float val) {
  return (int)(val * (float)(1 << 27));
}
Control Rate
// Transform inlet val to float in 0 > 1 range
float x = int2f(inlet_in);

// Transform curve param to float in 0 > 1 range
float a = int2f(param_curve);

// Quadratic Bezier interpolation
// http://blog.demofox.org/2014/08/28/one-dimensional-bezier-curves/
float outf = a * 2 * (1 - x) * x + (x * x);

// Output int
outlet_out = f2int(outf);

Privacy

© 2024 Zrna Research