diff options
author | bonmas14 <bonmas14@gmail.com> | 2025-08-04 13:33:47 +0000 |
---|---|---|
committer | bonmas14 <bonmas14@gmail.com> | 2025-08-04 13:33:47 +0000 |
commit | ed1cab483e49e29396178a33dea51773aa770855 (patch) | |
tree | 78102102f7f7d07be0e6bef4b10ef69576f0c23e /src/un_splines.c | |
parent | 471b539bdbf658ff7924b7500f89fd237df8be9b (diff) | |
download | ungrateful-ed1cab483e49e29396178a33dea51773aa770855.tar.gz ungrateful-ed1cab483e49e29396178a33dea51773aa770855.zip |
Math, not tested
Diffstat (limited to 'src/un_splines.c')
-rw-r--r-- | src/un_splines.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/un_splines.c b/src/un_splines.c new file mode 100644 index 0000000..7b27ee0 --- /dev/null +++ b/src/un_splines.c @@ -0,0 +1,40 @@ +real un_m_bezierr(real a, real q0, real q1, real b, real t) { + real i0, i1, i2, p1, p2; + + i0 = un_m_lerpr(a, q0, t); + i1 = un_m_lerpr(q0, q1, t); + i2 = un_m_lerpr(q1, b, t); + + p1 = un_m_lerpr(i0, i1, t); + p2 = un_m_lerpr(i1, i2, t); + + return un_m_lerpr(p1, p2, t); +} + +f32 un_m_bezierf(f32 a, f32 q0, f32 q1, f32 b, f32 t) { + f32 i0, i1, i2, p1, p2; + + i0 = un_m_lerpf(a, q0, t); + i1 = un_m_lerpf(q0, q1, t); + i2 = un_m_lerpf(q1, b, t); + + p1 = un_m_lerpf(i0, i1, t); + p2 = un_m_lerpf(i1, i2, t); + + return un_m_lerpf(p1, p2, t); +} + +f64 un_m_bezierd(f64 a, f64 q0, f64 q1, f64 b, f64 t) { + f64 i0, i1, i2, p1, p2; + + i0 = un_m_lerpd(a, q0, t); + i1 = un_m_lerpd(q0, q1, t); + i2 = un_m_lerpd(q1, b, t); + + p1 = un_m_lerpd(i0, i1, t); + p2 = un_m_lerpd(i1, i2, t); + + return un_m_lerpd(p1, p2, t); +} + +// add v2-4 variants |