-
Notifications
You must be signed in to change notification settings - Fork 3
/
col12.jscad
71 lines (60 loc) · 2.39 KB
/
col12.jscad
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
// PARAMETRES
function getParameterDefinitions() {
return [
{ name: 'nbp', type: 'int', initial: 12, caption: "Nombre de pans:" },
{ name: 'echX', type: 'float', initial: 1, caption: "Déformation(x):" },
{ name: 'echY', type: 'float', initial: 1, caption: "Déformation(y):" },
{ name: 'a1', type: 'float', initial: 0, caption: "Inclinaison(x):" },
{ name: 'd1', type: 'float', initial: 12.3, caption: "Décalage(x):" },
{ name: 'd2', type: 'float', initial: 25, caption: "Décalage(y):" },
{ name: 'piece', type: 'text',
initial :'polygon([[22,24/*1:0,0,0,0*/] ,[22,22.97] ,[22,21.94] ,[22,20.84] ,[22,19.81] ,[22,18.75] ,[22,17.72] ,[22,16.65] ,[22,15.56],[22,15/*1:0,-2,-16,2*/] ,[20.61,15.13] ,[19.32,15.16] ,[18.13,15.1] ,[17.02,14.96] ,[16.01,14.74] ,[14.79,14.33] ,[13.71,13.8] ,[12.76,13.17] ,[11.94,12.45] ,[11.24,11.66] ,[10.64,10.81] ,[10.15,9.9] ,[9.75,8.97] ,[9.43,8.01] ,[9.13,6.81] ,[8.94,5.62] ,[8.82,4.48] ,[8.78,3.41] ,[8.79,2.26] ,[8.86,1.16] ,[8.98,0.12],[9,0],[0,0],[0,24]]);',
caption: "Modèle:" },
{ name: 'antipiece', type: 'text', initial :'', caption: "Soustraire:" },
{ name: 'couleur', type: 'text', initial: 'BurlyWood', caption: "Couleur:"},
{ name: 'symetrie', type: 'choice',
values: ["BAS", ""], initial:"", captions: ["Bas+Droite", "Droite"], caption: 'Symétrie:'}
];
}
function main(params) {
function mi_profil(){
P = eval(params.piece);
S = params.antipiece;
if (S !== ''){
S = eval(S);
return P.subtract(S);
}
else
return P;
}
function profil(){
csg = union([mi_profil(), mi_profil().mirroredX()])
.scale([params.echX, params.echY, 1]);
return csg;
}
function volume(){
var a = 360/params.nbp, csg =[], i, A, B;
A = linear_extrude({height:0.65}, profil(params.echX));
for(i=0; i<params.nbp; i++){
B = rotate([params.a1, i*a, 0], A);
B = B.translate([params.d1 * sin(i*a),0, params.d1 * cos(i*a)]);
csg.push(B);
}
return union(csg);
}
function lampe(){
var csg = [], A;
A = volume();
if (params.symetrie === ''){
A = A.translate([0, -params.d2, 0]);
}
csg.push(A);
if (params.symetrie == 'BAS'){
A = A.rotateZ(180).translate([0, params.d2, 0]);
csg.push(A);
}
return color(params.couleur, union(csg));
}
L = center([true,true,false], lampe());
return L.translate([0,25,0]).rotateX(90);
}