k = 3; pi = 3.14159; // 3D line parameters smooth = 10; // line smoothing - WARNING: increasing this value too much causes the compilation to take a long time. line_w = 0.2; // line width //////////////////////////////////////// // FUNCTIONS function CinquefoilKnot(k, u) = let( x = cos(u)*(2 - cos(2* u/(2*k + 1))), y = sin(u)*(2 - cos(2* u/(2*k + 1))), z = -sin(2* u/(2*k + 1)) ) [x, y, z]; function getPoints() = [ for (u = [0:2:360*(k*4)]) CinquefoilKnot(k, u) ]; /////////////////////////////////// // MODULES module line(start, end){ hull() { translate(start) sphere(r=line_w, $fn=smooth); translate(end) sphere(r=line_w, $fn=smooth); } } module poly3Dline(points, index){ if(index < len(points)){ line(points[index - 1], points[index]); poly3Dline(points, index + 1); } } //////////////////////////////////////// // TEST scale(5) poly3Dline(getPoints(), 1);