Generates a list of random points that lie inside a tube
function random_points_inside_tube(r,r2,h,n)=
[for(i=[1:n])tube_point(r,r2,h)];
function tube_point(r,r2,h)=
let (p=[
rands(-r,r,1)[0],
rands(-r,r,1)[0],
rands(0,h,1)[0] ],
d=(pow(p.x,2) + pow(p.y,2) ))
d > pow(r,2)||d < pow(r2,2)?tube_point(r,r2,h):p;
p=random_points_inside_tube(50,30,100,1000);
for(t=p)translate(t) sphere(4);
echo(p);
No comments:
Post a Comment