! Copyright (C) 2010 Erik Charlebois
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel locals math math.combinatorics
-math.polynomials opengl.gl sequences ui.gadgets ui.gadgets.panes
-ui.render arrays grouping math.vectors assocs
-ui.gestures ;
+USING: arrays combinators grouping kernel math
+math.combinatorics math.polynomials math.vectors sequences ;
IN: math.splines
<PRIVATE
:: hermite-polynomial ( p0 m0 p1 m1 -- poly )
p0
- m0
+ m0
-3 p0 * -2 m0 * + 3 p1 * + m1 neg +
2 p0 * m0 + -2 p1 * + m1 +
4array ;
] each-index
] each-index
acc ;
-
+
:: <cubic-hermite-curve> ( p0 m0 p1 m1 -- polynomials )
- p0 length iota [
+ p0 length <iota> [
{
[ p0 nth ] [ m0 nth ]
[ p1 nth ] [ m1 nth ]