summaryrefslogtreecommitdiff
path: root/sly/math.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-10-03 11:57:02 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-10-03 11:57:02 -0400
commit283ec414e995fac7c8fc3024c94fd2113b1b701c (patch)
tree5dff4041f40ffc756651439463973c080af7fe81 /sly/math.scm
parent88a9c7cf0a6e0555ec8a5d21deac972a0f05de2e (diff)
transition: Move interpolation procedures to their relevant module.
* sly/color.scm (color-lerp): New procedure. * sly/math.scm (make-lerp, lerp): New procedures. * sly/math/vector.scm (vlerp): New procedure. * sly/transition.scm (interpolator, number-interpolate, vector-interpolate, color-interpolate): Delete procedures. (guess-interpolator): Rewrite with 'match-lambda*'.
Diffstat (limited to 'sly/math.scm')
-rw-r--r--sly/math.scm14
1 files changed, 13 insertions, 1 deletions
diff --git a/sly/math.scm b/sly/math.scm
index 4169ae4..923a93d 100644
--- a/sly/math.scm
+++ b/sly/math.scm
@@ -33,7 +33,8 @@
cotan
clamp
linear-scale
- half square))
+ half square
+ make-lerp lerp))
;; Dave was editing this module on Pi Approximation Day.
;;
@@ -110,3 +111,14 @@ actually less than MAX."
(define (square x)
(* x x))
+
+(define (make-lerp + *)
+ "Return a new procedure that accepts three arguments: A, B, and
+ALPHA. The returned procedure uses the procedures + and * to linearly
+interpolate a value between A and B. ALPHA should always be in the
+range [0, 1]."
+ (lambda (a b alpha)
+ (+ (* a (- 1 alpha))
+ (* b alpha))))
+
+(define lerp (make-lerp + *))