Wednesday, June 7, 2017

Figure Eight Path

Generates a path in the shape of figure eight


function figure8(m=100)=[for(t=[0:1:360])
let(scale = 2 / (3 - cos(2*t)),x =m* scale * cos(t),y =m* scale * sin(2*t) / 2)
[x,y]];

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(figure8(50))); 

No comments:

Post a Comment