-
Notifications
You must be signed in to change notification settings - Fork 13
/
bearears-exp.scad
executable file
·105 lines (90 loc) · 3.55 KB
/
bearears-exp.scad
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
99
100
101
102
103
104
105
use <bezier.scad>;
use <paths.scad>;
//<params>
headbandWidth = 140;
headbandHeightRatio = 1.1;
headbandStripWidth = 10;
headbandStripThickness = 2.5;
toothedRatio = .7;
toothSpacing = 3;
toothThickness = 1;
toothLength = 1;
toothWidthRatio = 0.5;
headbandBottomFlare = 1; // [0:no, 1:yes]
earPosition = 0.3;
earAngle1FromVertical = -20;
earAngle2FromVertical = -20;
earStickoutForce1 = 2;
earStickoutForce2 = 2;
earThickness = 5;
earBackingThickness = 1;
earSize = 70;
earInnerRatio = 0.5;
module dummy() {}
//</params>
nudge = 0.01;
headbandHeight = headbandWidth * headbandHeightRatio;
pointsRight = Bezier([
[0,headbandHeight], /*C*/POLAR(headbandWidth/4,0), /*C*/POLAR(headbandWidth/4,90), [headbandWidth/2,headbandHeight/2],
/*C*/SYMMETRIC(), /*C*/POLAR(headbandWidth/(headbandBottomFlare?6:4),headbandBottomFlare?90:60),[headbandWidth/4,0]]);
interp = interpolationData(pointsRight);
length = totalLength(interp);
module rightSide() {
segmentLength = headbandStripWidth/3;
segments = floor(length / segmentLength);
for(i=[0:segments-1]) {
adjust = i < segments-1 ? 0 : (1/(2+sqrt(2)))* headbandStripWidth;
a = interpolateByDistance(interp, i*segmentLength);
b = interpolateByDistance(interp, (i+1)*segmentLength);
hull() {
translate(a) cylinder(d=headbandStripThickness,h=headbandStripWidth,$fn=16);
translate([b[0],b[1],adjust]) cylinder(d=headbandStripThickness,h=headbandStripWidth-2*adjust,$fn=16);
}
}
if (toothedRatio>0) {
teeth = floor(length * toothedRatio / toothSpacing);
for(i=[0:teeth-1]) {
d = i * toothSpacing;
tangent = getTangentByDistance(interp, d);
normal = [tangent[1],-tangent[0]];
a = interpolateByDistance(interp, d);
hull() {
translate(a) cylinder(h=toothWidthRatio*headbandStripWidth,d=toothThickness);
translate(a+(toothLength+headbandStripThickness*0.5)*normal) cylinder(h=toothWidthRatio*headbandStripWidth,d=toothThickness);
}
}
}
module ear(earSize) {
earStart = earPosition * length - earSize / 2;
earEnd = earPosition * length + earSize / 2;
earPoints0 = [for (d=[earStart:1:earEnd]) interpolateByDistance(interp,d)];
a = interpolateByDistance(interp,earStart);
b = interpolateByDistance(interp,earEnd);
earAngle = atan2(b[1]-a[1],b[0]-a[0]);
c = (a+b)/2;
r = norm(c-a);
rot = [ [ cos(earAngle), -sin(earAngle) ],
[ sin(earAngle), cos(earAngle) ] ];
earPoints1a = Bezier( [[-1,0], POLAR(earStickoutForce1,90-earAngle1FromVertical), POLAR(earStickoutForce2,90+earAngle2FromVertical), [1,0]]); // ,
earPoints1 = [for (v=r*earPoints1a) c+rot*v];
earPoints = concat(earPoints0,earPoints1);
earCenterPoint = interpolateByDistance(interp,(earStart+earEnd)/2);
earTangent = getTangentByDistance(interp,(earStart+earEnd)/2);
earNormal = [-earTangent[1],earTangent[0]];
linear_extrude(height=earThickness+earBackingThickness)
polygon(earPoints);
linear_extrude(height=earBackingThickness)
polygon(earPoints);
}
difference() {
ear(earSize);
translate([0,0,(earThickness+earBackingThickness)/2])
ear(earSize*earInnerRatio);
}
}
module headband() {
rightSide();
mirror([1,0,0]) rightSide();
}
//render(convexity=2)
headband();