-
Notifications
You must be signed in to change notification settings - Fork 13
/
barndoorcorrect.scad
executable file
·106 lines (96 loc) · 3.39 KB
/
barndoorcorrect.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
106
headHeight = 3.4; // Thickness of spherical portion of bolt head
headWidth = 14.73; // Width of spherical portion of bolt head
extraThickness = 1; // Extra thickness of adjustment device
tolerance = 0.2; // We assume filament goes this far beyond its boundaries; set to 0 for 2D cutting
initialStickout = 3.07; // The top of the bolt head sticks out this far past the horizontal plane through the hinge
distanceFromHinge = 292; // Distance from the rotational center of the hinge to the bolt
threadPitch = 1.27; // in mm: 20 tpi = 1.27
rpm = 1; // Planned speed of bolt rotation
distanceToEnd = 35; // Distance from center of bolt to the end of the board
correctorWidth = 20;
extraGap = 2; // extra gap between boards at zero angle
maxTime = 120; // in minutes
dimensions = 3; // choose 2 or 3
module dummy() {}
animate = 0;
adjustedStickout = initialStickout+extraThickness+tolerance;
headRadius = (pow((headWidth/2),2)+headHeight*headHeight)/(2*headHeight);
siderealDay = 23.9344699;
skyDegPerMin = 360*(24/siderealDay)/24/60;
function position(t) = adjustedStickout+1.27*rpm*t;
initialAngle = asin(position(0)/distanceFromHinge);
function angle(t) = initialAngle+skyDegPerMin*t;
module head(sweepBack=false) {
render()
translate([0,headRadius]) {
intersection() {
circle(r=headRadius,$fn=72);
translate([-headRadius,-3*headRadius+headHeight]) square(2*headRadius);
}
if (sweepBack) {
translate([-headWidth/2,-headRadius+headHeight]) square([headWidth,distanceToEnd]);
}
}
}
module bump(t) {
render(convexity=2)
rotate(angle(t))
translate([distanceFromHinge,-position(t)]) {
head(sweepBack=true);
}
}
module arm(t) {
render(convexity=2)
translate([0,-correctorWidth,-1]) cube([distanceFromHinge+distanceToEnd,correctorWidth,2]);
rotate([0,-angle(t),0]) {
translate([0,-correctorWidth,-1]) cube([distanceFromHinge+distanceToEnd,correctorWidth,2]);
translate([distanceFromHinge,-correctorWidth/2,-position(t)]) {
rotate_extrude()
{
intersection() {
union() {
translate([-headWidth*.1,headHeight]) square([headWidth*.2,position(t)-headHeight]);
head();
}
translate([0,0]) square([headWidth,position(t)]);
}
}
}
}
}
module corrector() {
maxAngle = angle(maxTime);
p = position(maxTime);
r1 = norm([distanceFromHinge,p]);
theta = maxAngle-atan2(p,distanceFromHinge);
maxHeight=r1 * sin(theta)+extraGap;
module flat() {
difference() {
translate([-headWidth/3,0]) square([distanceToEnd+headWidth/3,maxHeight+extraGap]);
translate([-distanceFromHinge,extraThickness+extraGap])
for (t=[0:.1:2*maxTime])
bump(t);
}
}
if (dimensions==3)
linear_extrude(height=correctorWidth) flat();
else
flat();
}
/*
if (animate) {
for (t=[0:1:$t*maxTime]) {
bump(t, attachments=false);
}
bump($t*maxTime,attachments=true);
}
*/
if (animate) {
translate([0,0,-extraThickness])
rotate([90,0,0])
translate([distanceFromHinge,0,0]) corrector();
arm($t*60);
}
else {
corrector();
}