Skip to content

Instantly share code, notes, and snippets.

@guyc
Created April 27, 2013 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyc/5472760 to your computer and use it in GitHub Desktop.
Save guyc/5472760 to your computer and use it in GitHub Desktop.
openscan source for one tentacle arc.
// arc is defined by the inner radius
small = 1;
$fa = 4;
//$fs = 1;
segmentInnerRadius = 300;
segmentArc = 10; // degrees
segmentWidth = 40;
segmentDepth = 20;
bulgeRadius = 60;
segmentOuterRadius = segmentInnerRadius+segmentDepth;
tunnelInset = 8;
tunnelRadius = 5;
module segment()
{
translate([0,-segmentInnerRadius,0])
{
intersection()
{
envelope();
bulgeEnvelope();
rotate(a=[0,90,0])
{
difference()
{
cylinder(r=segmentOuterRadius, h=segmentWidth,center=true);
cylinder(r=segmentInnerRadius, h=segmentWidth+small,center=true);
torus(segmentInnerRadius+tunnelInset, tunnelRadius);
}
}
}
}
}
// r1 is donut radius, r2 is crosssectional radius
module torus(r1, r2)
{
rotate_extrude(convexity = 10)
{
translate([r1, 0, 0])
{
circle(r = r2);
}
}
}
module tunnel()
{
rotate(a=[0,90,0])
{
torus(segmentInnerRadius+tunnelInset, tunnelRadius);
}
}
module bulgeEnvelope()
{
ax = segmentWidth/2;
ay = 0;
bx = 0;
by = segmentDepth;
dab = sqrt(ax*ax+by*by);
angleab = atan(by/ax);
angleabc = acos(dab/2/bulgeRadius);
angleac = angleabc - angleab;
cx = ax - bulgeRadius * cos(angleac);
cy = ay - bulgeRadius * sin(angleac);
echo("angleab",angleab,", angleabc",angleabc,",angleac",angleac);
echo("cx=",cx,", cy=",cy);
echo("d=",sqrt((cx-ax)*(cx-ax)+(cy-ay)*(cy-ay)));
rotate(a=[0,90,0])
{
intersection()
{
translate([0,0,-cx]) torus(segmentInnerRadius+cy,bulgeRadius);
translate([0,0,+cx]) torus(segmentInnerRadius+cy,bulgeRadius);
}
}
}
module envelope()
{
top = segmentOuterRadius * tan(segmentArc);
polyhedron(
points =
[
[-segmentWidth,0,0],
[-segmentWidth,segmentOuterRadius+small,0],
[-segmentWidth,segmentOuterRadius+small,top],
[+segmentWidth,0,0],
[+segmentWidth,segmentOuterRadius+small,0],
[+segmentWidth,segmentOuterRadius+small,top],
],
triangles =
[
[0,1,2],
[3,5,4],
[0,2,5,3],
[1,0,3,4],
[1,4,5,2]
]
);
}
segment();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment