Parametric teardrop script
by mattroberts, published
Description
Basically this is a better parametric teardrop. I wanted to be able to create teardrop hex nut holes, so I added a parameter for number of sides - which then means that you naturally want a few more parameters as well.
File has been updated to version 2, original version can still be downloaded if you wish.
Recent Comments
view allMmm... I think the problem is caused by co-linear edges. So I've tried to avoid those (now the linear extrusion stuff works using overlapping quads).
Please tell me if you think this works... if it does I'll update teardrop.scad
// internal code - don't call this...
module teardrop2(r, l, a, a2, n) {
rotate([0,a,0])
assign(m=(a
&
gt;45) ? sqrt(1 - pow(sin(90-a),2)) : 0)
for (i = [1:n])
assign(u=a2+360*i/n, v=a2+360*(i+1)/n)
assign(x1=r*sin(u), y1=r*cos(u), x2=r*sin(v), y2=r*cos(v),x3=r*sin(u-90)/2, y3=r*cos(u-90)/2,x4=r*sin(v+90)/2,y4=r*cos(v+90)/2)
union() {
linear_extrude(height=l, center=true) polygon([[x3,y3], [x1,y1], [x2,y2], [x4,y4]]);
if (m
&
gt; 0) {
if(y2
&
lt;0
&
amp;
&
amp; y3
&
lt;y4)
linear_extrude(height=l, center=true) polygon([[x2-abs(y2)*m,0], [x2,y2],[x3,y3],[x4,y4]]);
if(y1
&
gt;0
&
amp;
&
amp; y3
&
lt;y4)
linear_extrude(height=l, center=true) polygon([[x1,y1], [x1-abs(y1)*m,0], [x3,y3], [x4,y4]]);
}
}
}
I found a solution (almost)!
module teardrop2(r, l, a, a2, n) {
rotate([0,a,0])
assign(m=(a
&
gt;45) ? sqrt(1 - pow(sin(90-a),2)) : 0)
union(){
for (i = [1:n]){
linear_extrude(height=l, center=true) polygon([[0,0], [r*sin(a2+360*i/n),r*cos(a2+360*i/n)], [r*sin(a2+360*(i+1)/n),r*cos(a2+360*(i+1)/n)]]);
if (m
&
gt; 0) {
linear_extrude(height=l, center=true) polygon(points=[[r*sin(a2+360*i/n),r*cos(a2+360*i/n)], [r*sin(a2+360*i/n)-abs(r*cos(a2+360*i/n))*m,0], [r*sin(a2+360*(i+1)/n)-abs(r*cos(a2+360*(i+1)/n))*m,0], [r*sin(a2+360*(i+1)/n),r*cos(a2+360*(i+1)/n)]]);
}
}
}
}
I combined the 3rd linear_extrude with the 2nd one, so that you get: linear_extrude(height=l, center=true) polygon([[x1,y1], [x1-abs(y1)*m,0], [x2-abs(y2)*m,0], [x2,y2]]);
In the top, there is still a error (very small) i can't remove. When fn=6, the problem is gone.
The following is a teardrop,
within a teardrop, with in a teardrop.
difference(){
cube(size=[9,9,13],center=true);
teardrop(r=3, length=11, angle=90, fn=6);
rotate([0,0,90])
teardrop(r=3, length=11, angle=90, fn=6);
}
difference(){
intersection(){
teardrop(r=3, length=11, angle=90, fn=6);
rotate([0,0,90])
teardrop(r=3, leng
th=11, angle=90, fn=6);
}
teardrop(r=1.5, length=11, angle=90, fn=2);
}
Remixed From
Tags
Give a Shout Out
Instructions
teardrop
make sure to only specify one radius or diameter parameter - there are several to choose from
"r" or "or" specify the maximum or outer radius of the object,
"ir" specifies the minimum or inner radius
"d", "od" and "id" are the same for specifying in terms of diameter - "id" is useful for specifying the across flats distance for nuts
"length" is the length of the teardrop
"angle" is the angle from vertical of the teardrop - 0 degrees is a vertical hole, 90 degrees is horizontal
"fn" is the number of sides of the 'cylinder' - set to 6 for a teardrop hex nut
"angle2" is the rotation of the 'cylinder' around its axis
Comments
You must be logged in to post a comment.


Nice script! But i have problems with the following example:
difference(){
cube(size=[9,9,13],center=true);
teardrop(4.5, 10, 90);
}
I tried everything, but i can't get it correct.
press F6 (CGAL mode)
you pressed F5... that view sometimes doesn't quite work (and that depends if it in OpenCSG mode or not).
(I tried your example, and for what it is worth - i get the same view with F5, but it works perfectly with F6)