! Copyright (C) 2010 Erik Charlebois.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel locals math math.order math.polynomials
-math.splines opengl.gl sequences ui.gadgets ui.gadgets.panes ui.render
-arrays ;
+USING: accessors kernel math math.order math.polynomials
+opengl.demo-support opengl.gl sequences ui.gadgets
+ui.gadgets.panes ui.render arrays ;
IN: math.splines.viewer
<PRIVATE
: eval-polynomials ( polynomials-seq n -- xy-sequence )
[
- [ 1 + iota ] keep [
+ [ 1 + <iota> ] keep [
/f swap [ polyval ] with map
] curry with map
] curry map concat ;
[ first x-min - x-max x-min - / gadget spline-dim>> first * ]
[ second y-min - y-max y-min - / gadget spline-dim>> second * ] bi 2array
] map :> pts
-
- GL_LINE_STRIP glBegin
- pts [
- first2 neg gadget spline-dim>> second + glVertex2f
- ] each
- glEnd ;
+
+ GL_LINE_STRIP [
+ pts [
+ first2 neg gadget spline-dim>> second + glVertex2f
+ ] each ]
+ do-state ;
:: <spline-gadget> ( polynomials dim steps -- gadget )
spline-gadget new
dim >>spline-dim
- polynomials >>polynomials
+ polynomials >>polynomials
steps >>steps ;
: spline. ( curve dim steps -- )
- <spline-gadget> gadget. ;
+ <spline-gadget> gadget. ;