]> gitweb.factorcode.org Git - factor.git/blob - extra/math/splines/testing/testing.factor
factor: trim using lists
[factor.git] / extra / math / splines / testing / testing.factor
1 ! Copyright (C) 2010 Erik Charlebois.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays math.splines math.splines.viewer ;
4 IN: math.splines.testing
5
6 : test1 ( -- )
7     {
8         { { 0 0 } { 0 200 } }
9         { { 100 50 } { 0 -200 } }
10         { { 300 300 } { 500 200 } }
11         { { 400 400 } { 300 0 } }
12     } <cubic-hermite-spline> { 50 100 } 4 spline. ;
13
14 : test2 ( -- )
15     {
16         { 50 50 }
17         { 100 100 }
18         { 300 200 }
19         { 350 0 }
20         { 400 400 }
21     } { 0 100 } { 100 0 } <catmull-rom-spline> { 100 50 } 50 spline. ;
22
23 :: test3 ( x y z -- )
24     {
25         { 100 50 }
26         { 200 350 }
27         { 300 50 }
28     } { 0 100 } { 0 -100 } x y z <kochanek-bartels-curve> { 50 50 } 1000 spline. ;
29
30 : test4 ( -- )
31     {
32         { 0 5 }
33         { 0.5 3 }
34         { 10 10 }
35         { 12 4 }
36         { 15 5 }
37     } <bezier-curve> 1array { 100 100 } 100 spline. ;
38
39 : test-splines ( -- )
40     test1 test2
41     1 0 0 test3
42     -1 0 0 test3
43     0 1 0 test3
44     0 -1 0 test3
45     0 0 1 test3
46     0 0 -1 test3
47     test4 ;