From ce9204d85877dce00651522902b9d5540e6cfe42 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Tue, 4 Dec 2007 16:42:28 +0000 Subject: [PATCH] What's a hermite spline without derivates? I suggest we add getSlope() or something like it to the interface/superclass; thoughts? git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@360 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/path/HermiteFunc.as | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/as/com/threerings/flash/path/HermiteFunc.as b/src/as/com/threerings/flash/path/HermiteFunc.as index a13f0c5b..e4dcd988 100644 --- a/src/as/com/threerings/flash/path/HermiteFunc.as +++ b/src/as/com/threerings/flash/path/HermiteFunc.as @@ -53,6 +53,19 @@ public class HermiteFunc extends InterpFunc } } + /** Get the derivate of this function at a point. */ + public function getSlope (t :Number) :int + { + if (t >= 1 || t < 0) { // cope with a funny startOffset + return 0; + } + var tt :Number = t*t; + + return int((_p0 - _p1) * (6*tt - 6*t) + + _m0 * (3*tt - 4*t + 1) + + _m1 * (3*tt - 2*t)); + } + /** The coefficient for the spline that interpolates the beginning point value. */ protected var _p0 :Number;