-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbarbell.scad
82 lines (71 loc) · 1.63 KB
/
barbell.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
//
// differential_planetary_gearbox
//
// Copyright 2014 by Ron Aldrich.
//
// License: CC-By-SA - http://creativecommons.org/licenses/by-sa/3.0/deed.en_US
//
// barbell.scad
//
// Barbell function extracted from "Greg's Hinged Accessible Extruder"
// http://www.thingiverse.com/thing:8252
//
$fa=1;
$fs=1;
function triangulate (point1, point2, length1, length2) =
point1 +
length1*rotated(
atan2(point2[1]-point1[1],point2[0]-point1[0])+
angle(distance(point1,point2),length1,length2));
function distance(point1,point2)=
sqrt((point1[0]-point2[0])*(point1[0]-point2[0])+
(point1[1]-point2[1])*(point1[1]-point2[1]));
function angle(a,b,c) = acos((a*a+b*b-c*c)/(2*a*b));
function rotated(a)=[cos(a),sin(a),0];
module barbell (x1,x2,r1,r2,r3,r4)
{
x3=triangulate (x1,x2,r1+r3,r2+r3);
x4=triangulate (x2,x1,r2+r4,r1+r4);
render()
difference ()
{
union()
{
translate(x1)
circle (r=r1);
translate(x2)
circle(r=r2);
polygon (points=[x1,x3,x2,x4]);
}
translate(x3)
circle(r=r3);
translate(x4)
circle(r=r4);
}
}
module barbell_void_1 (x1,x2,r1,r2,r3,r4)
{
x3=triangulate (x1,x2,r1+r3,r2+r3);
x4=triangulate (x2,x1,r2+r4,r1+r4);
translate(x3)
circle(r=r3);
}
module rounded_triangle(x1, x2, x3, r1, r2, r3, r4, r5, r6)
{
x4 = triangulate(x2, x1, r2+r4, r1+r4);
x5 = triangulate(x3, x2, r3+r5, r2+r5);
x6 = triangulate(x1, x3, r1+r6, r3+r6);
difference()
{
union()
{
translate(x1) circle(r=r1);
translate(x2) circle(r=r2);
translate(x3) circle(r=r3);
polygon(points = [x1, x4, x2, x5, x3, x6]);
}
translate(x4) circle(r=r4);
translate(x5) circle(r=r5);
translate(x6) circle(r=r6);
}
}