diff src/dmcurves.c @ 978:fecf3967abee

Move lerp functions from dmlerp.c to dmcurves.c, too.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Feb 2015 16:20:24 +0200
parents 1b439304ff3c
children 0ba1ec9b8608
line wrap: on
line diff
--- a/src/dmcurves.c	Fri Feb 27 16:18:08 2015 +0200
+++ b/src/dmcurves.c	Fri Feb 27 16:20:24 2015 +0200
@@ -7,6 +7,26 @@
 #include "dmcurves.h"
 
 
+void dmLerpInit(DMLerpContext *ctx, DMFloat start, DMFloat end, DMFloat nsteps)
+{
+    ctx->start = start;
+    ctx->end = end;
+    ctx->nsteps = nsteps;
+}
+
+
+DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3)
+{
+    const DMFloat q = t * t;
+    return (
+        (2 * p1) +
+        (-p0 + p2) * t +
+        (2 * p0 - 5 * p1 + 4 * p2 - p3) * q +
+        (   -p0 + 3 * p1 - 3 * p2 + p3) * q * t
+        ) * 0.5f;
+}
+
+
 static inline const DMVector *dmSplineGetPoint(const DMVector *points, const int npoints, const int n)
 {
     return (n < 0) ? &points[0] : ((n < npoints) ? &points[n] : &points[npoints - 1]);