-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnurbs.html
73 lines (62 loc) · 1.77 KB
/
nurbs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="800" height="600">No <canvas> support</canvas>
<script src="splines.js"></script>
<script>"use strict";
/*
Various spline-related demos
Copyright (C) 2015 Jona Stubbe
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.*/
var ctx = document.getElementById('canvas').getContext('2d');
var bezier_circle = [[
[100,300,1],
[100,0,1],
[800,0,2]
],[
[400,0,1],
[700,0,1],
[1400,600,2]
],[
[700,300,1],
[700,600,1],
[800,1200,2]
],[
[400,600,1],
[100,600,1],
[200,600,2]
]];
//for (var i in bezier_circle) rationalBezier(ctx, bezier_circle[i]);
var bspline_circle = [
[400,0,1],
[100,0,1],
[200,600,2],
[100,600,1],
[400,600,1],
[700,600,1],
[1400,600,2],
[700,0,1],
[400,0,1]
];
var circle_knots = [0,0,0,.25,.25,.5,.5,.75,.75,1,1,1];
var nurbsbook_knots = [0,0,0,1,2,3,4,4,5,5,5];
var bezier2_knots = [0,0,0,1,1,1];
var bfuncs = bSplineBasisFuncs(2, bezier2_knots);
console.log(bfuncs);
for (var i in bfuncs)
plotFunc(ctx, bfuncs[i], 0, 1);
var weight = Math.sqrt(2)/2;
bSpline(ctx, 2, bspline_circle, circle_knots);
</script>
</body>
</html>