-
Notifications
You must be signed in to change notification settings - Fork 0
/
classwork4-5-2012.js
98 lines (72 loc) · 2.66 KB
/
classwork4-5-2012.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var domain = INTERVALS(1)(40);
var points1 = [[1,0,0],[0,1,0],[0,2,0],[-2,0,0]];
var cMap1 = CUBIC_HERMITE(S0)(points1);
var c = COLOR([1,1,0])(MAP(cMap1)(domain));
//DRAW(c);
var points2 = [[2,0,0],[0,2,0],[0,3,0],[-3,0,0]];
var cMap2 = CUBIC_HERMITE(S0)(points2);
var c2 = COLOR([0,1,1])(MAP(cMap2)(domain));
//DRAW(c2);
//DIAMO le curve in pasto ad una funzione di Bezier per ottenere una superficie
var domainB = DOMAIN([[0,1],[0,1]])([30,50])
var curves = [cMap1, cMap2];
var bMap = BEZIER(S1)(curves);
var s12 = MAP(bMap)(domainB);
//DRAW(s12);
//FACCIAMO UNA SUPERFICIE tipo tunnel
var mapSur = CUBIC_HERMITE(S1)([cMap1, cMap2, [0,0,3],[0,0,-3]]);
var sur12 = MAP(mapSur)(domainB);
//DRAW(SKELETON(1)(sur12));
//prende array di punti e restituisce complesso simpliciale fatto solo con quei punti
var POLYPOINT = function(points){
var list = [];
points.forEach(function(v, i){list.push([i]);})
return SIMPLICIAL_COMPLEX(points)(list);
}
var p1 = POLYPOINT([[10,0,0],[0,5,0],[0,-3,0],[5,2,0],[10,0,0]]);
//DRAW(COLOR([1,0,0])(p1));
//superficie alare
var p1 = [[10,0,0],[0,5,0],[0,-3,0],[5,2,0],[10,0,0]];
var alaBez = BEZIER(S0)(p1);
var cAla = MAP(alaBez)(domain);
//DRAW(cAla);
var p2 = p1.map(function(p){ return [p[0], p[1], p[2] + 10];});
var p3 = p2.map(function(p){ return [p[0], p[1], p[2] + 10];});
var p4 = p3.map(function(p){ return [p[0], p[1], p[2] + 10];});
var p5 = p4.map(function(p){ return [p[0], p[1], p[2] + 10];});
var cpt0 = BEZIER(S0)(p1);
var cpt1 = BEZIER(S0)(p2);
var cpt2 = BEZIER(S0)(p3);
var cpt3 = BEZIER(S0)(p4);
var cpt4 = BEZIER(S0)(p5);
var curva = STRUCT(CONS(AA(MAP)([cpt0, cpt1, cpt2, cpt3, cpt4]))(domainB));
//DRAW(curva);
var wing = BEZIER(S1)([cpt0,cpt1,cpt2,cpt3,cpt4]);
var wingImage = MAP(wing)(domainB);
//DRAW(wingImage);
//NUBS --> non uniform BSPLINE
// NUBS(S0)(2)(controlpoints)
// es. m=5, k=2 --> nodi=8
//per interpolare nodo inziale e finale vanno ripetuti 3 volte
var controls = [[0,0,0], [2,5,0],[7,3,0],[9,7,0],[12,2,0]];
var knots = [0,0,0,1,2,3,3,3];
var c1 = NUBS(S0)(2)(knots)(controls);
var curve1 = MAP(c1)(domain);
//DRAW(curve1);
var controls2 = [[0,0,0], [2,5,3],[7,3,6],[9,7,-2],[12,2,-3]];
var knots2 = [0,0,0,1,2,3,3,3];
var c2 = NUBS(S0)(2)(knots2)(controls2);
var curve2 = MAP(c2)(domain);
//DRAW(curve2);
var surface12 = BEZIER(S1)([c1, c2]);
var s12 = MAP(surface12)(domainB);
//DRAW(s12);
//var sup1 = BEZIER(S1)([cpt0, cpt1]);
//var sup2 = BEZIER(S1)([cpt3, cpt4]);
//var domain3d = DOMAIN([[0,1],[0,1],[0,1]])([10,10,10]);
//var solid = BEZIER(S2)([sup1, sup2]);
//var solidBez = MAP(solid)(domain3d);
//DRAW(solidBez);
/////////////
var body = R([0,2])([PI/2])(CYL_SURFACE([5,25])([100,100]));
DRAW(body);