Skip to content

Instantly share code, notes, and snippets.

@zoe1337
Created March 30, 2021 12:08
Show Gist options
  • Save zoe1337/d639fa172d7ee44fb20219d71b6530b9 to your computer and use it in GitHub Desktop.
Save zoe1337/d639fa172d7ee44fb20219d71b6530b9 to your computer and use it in GitHub Desktop.
Simple pipeline tool in openscad
pipeCoords = [
[0,0,0],
[0,2,9],
[0,4,15],
[0,6,21],
[0,15,35],
[0,26,50],
[0,32,59],
[0,41,74],
[0,44,82],
[0,45,87],
[0,45.00001,99]];
module pipeline(coordinates, diameter) {
N = len(coordinates);
assert(N>1);
for (i=[0:N-2]) {
origin = coordinates[i];
delta = coordinates[i+1] - origin;
length = sqrt(delta.x*delta.x + delta.y*delta.y + delta.z*delta.z);
inclination = atan2(delta.y,delta.x);
azimuth = acos(delta.z/length);
translate(origin) {
sphere(d=diameter);
rotate([0,0,inclination])
rotate([0,azimuth,0])
cylinder(d=diameter, h=length);
}
translate(coordinates[N-1])
sphere(d=diameter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment