-
Notifications
You must be signed in to change notification settings - Fork 0
/
timpano.js
84 lines (76 loc) · 2.32 KB
/
timpano.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
var domain = INTERVALS(1)(80);
var domain2d = DOMAIN([[0,1],[0,1]])([80,10]);
var domain3d = DOMAIN([[0,1],[0,1],[0,1]])([80,10,1]);
var PointUtils = function() {};
PointUtils.ruotaPunti = function(pointList, angolo, asse) {
if (asse === 0) {
var alfa = angolo;
return pointList.map( function(pt) {
return [ pt[0], pt[1]*COS(alfa) + (-1)*pt[2]*SIN(alfa), pt[1]*SIN(alfa) + pt[2]*COS(alfa) ];
});
} else if (asse === 1) {
var beta = angolo;
return pointList.map( function(pt) {
return [ pt[0]*COS(beta) + pt[2]*SIN(beta), pt[1], (-1)*pt[0]*SIN(beta) + pt[2]*COS(beta) ];
});
} else if (asse === 2) {
var gamma = angolo;
return pointList.map( function(pt) {
return [ pt[0]*COS(gamma) + (-1)*pt[1]*SIN(gamma), pt[0]*SIN(gamma) + pt[1]*COS(gamma), pt[2] ];
});
}
return pointList;
};
PointUtils.ribaltaPunti = function(pointList, asse) {
if (asse === 0) {
return pointList.map( function(pt) {
return [ -pt[0], pt[1], pt[2] ];
});
} else if (asse === 1) {
return pointList.map( function(pt) {
return [ pt[0], -pt[1], pt[2] ];
});
} else if (asse === 2) {
return pointList.map( function(pt) {
return [ pt[0], pt[1], -pt[2] ];
});
}
};
PointUtils.traslaPunti = function(pointList, asse, qty) {
if (asse === 0) {
return pointList.map( function(pt) {
return [ pt[0]+qty, pt[1], pt[2] ];
});
} else if (asse === 1) {
return pointList.map( function(pt) {
return [ pt[0], pt[1]+qty, pt[2] ];
});
} else if (asse === 2) {
return pointList.map( function(pt) {
return [ pt[0], pt[1], pt[2]+qty ];
});
}
};
PointUtils.scalaPunti = function(pointList, scalamento) {
return pointList.map( function(pt) {
return [ pt[0] * scalamento, pt[1], pt[2]];
});
};
PointUtils.scalaPuntiY = function(pointList, scalamento) {
return pointList.map( function(pt) {
return [ pt[0], pt[1]*scalamento, pt[2]];
});
};
var makeKnots = function(points){
var knots = [0,0,0];
var tot = points.length;
for(var i=1;i<=tot-3;i++)
knots.push(i);
knots.push(i);
knots.push(i);
knots.push(i);
return knots;}
DRAW(timpano);
DRAW(timpanoLeft);
DRAW(timpanoRight);