Thursday, June 8, 2017

Circle Path

Generates a path in the shape of a circle

 
function circle(r=100,steps=100)=
[ for(t=[0:1/steps:1])
let(  x =r* sin(t*360),   y =r*cos(t*360)  )
[x,y] ];
// function close adds a last point equal yo the first
function close(p)= concat(p,[p[0]]);

module polyline(p) {for(i=[0:max(0,len(p)-2)])line(p[i],p[i+1]);} module line(p1, p2 ,width=0.5) { hull() { translate(p1) sphere(width); translate(p2) sphere(width); } } polyline(close(circle()));

No comments:

Post a Comment