$fn behaviour

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

$fn behaviour

mondo

In the user manual it mentions - TIP: If you want to create a circle/cylinder/sphere which has an axis aligned integer bounding box (i.e. a bounding box that has integral dimensions, and an integral position) use a value of $fn that is divisible by 4.

In my recent creation, I'v found, for the first time, that there are a number of $fn which do not allow the model to be rendered. Values such as 20, 24, 40, 100 and many other fail, but 25, 50, 75 are OK.

80 fails, 81 is OK, etc. Is this behaviour expected, I've not found it happening before, but  I'm not a heavy user? If it is normal, then it is not a problem to me, providedIi expect it to occur. The object has a number of curved surfaces - I've been rounding off corners.




module inside(){
 polygon(points=[[0,0],[0,43],[43,43],[43,30],[48,30],[48,13],[43,13],[43,0]]);
}


module round(r){
   difference(){
       square(2*r+0.001,true);
          translate([r,r]) circle(r);
          translate([-r,r]) circle(r);
          translate([r,-r]) circle(r);
          translate([-r,-r]) circle(r);
   }
}


module fillet(r,h){
       difference() {
           translate([0,0,h/2]) cube([2*r + 0.001, 2*r + 0.001, h], center = true);
               translate([r, r, 0]) cylinder(h,r,r);
               translate([-r, r, 0]) cylinder(h,r,r);
               translate([-r, -r, 0]) cylinder(h,r,r);
               translate([r,- r, 0]) cylinder(h,r,r);
    }
}


module roundinside(){
    union(){
         difference(){
              inside();
                  translate([0,0])round(8);
                  translate([43,0])round(8);
                  translate([43,43])round(8);
                  translate([0,43])round(8);
                  translate([48,30])round(4);
                  translate([48,13])round(4); 
         }
      translate([43,30])round(1.5);
      translate([43,13])round(1.5); 
}  
}


module outside(){
offset(1.5) roundinside();
}


module wall(){
    difference(){
        outside();
            roundinside();
    }
}

$fn=81;

difference(){
    union(){
        linear_extrude(10)wall();
        translate ([-8,17,0])cube([8,10,10]);
        translate ([-1.5,17,0])fillet(1.2,10);   
        translate ([-1.5,27,0])fillet(1.2,10);    
     }
    translate([-4.5, 10,5]) rotate ([-90,0,0])cylinder (20,1.5,1.5);
    translate([-20,22,0])cube([20,1,20]);
    translate([-8,0,0])rotate([-90,0,0])fillet(3,50);
    translate([-8,0,10])rotate([-90,0,0])fillet(3,50);

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

Parkinbot
Well, your design gets rendered, it can be exported, and at least Kisslicer (which I usually use to check for printability) does not complain about any deformity.
I get this warning quite often and do not always care about it, if a design looks resonably well in the slicer.

Usually the cause is that there are vertices situated too close to each other so that they (possibly) snap to the same point. Changing $fn a bit, can be a way to get out the problem. If this doesn't help, I use the slicer to visualize, where the problem is. Then I add some small values (0.01) to the relevant design parameter to escape the warning.

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

thehans
In reply to this post by mondo
The circles in your "round" module are touching at single points, which is not manifold.

If you modify it to only round one corner at a time, and rotate appropriately at each position, then  it works fine.

module inside(){
 polygon(points=[[0,0],[0,43],[43,43],[43,30],[48,30],[48,13],[43,13],[43,0]]);
}

module round(r,corner=0){
   rotate(corner*90) difference(){
       square(2*r+0.001,true);
       translate([r,r]) circle(r);
   }
}

module fillet(r,h){
       difference() {
           translate([0,0,h/2]) cube([2*r + 0.001, 2*r + 0.001, h], center = true);
               translate([r, r, 0]) cylinder(h,r,r);
               translate([-r, r, 0]) cylinder(h,r,r);
               translate([-r, -r, 0]) cylinder(h,r,r);
               translate([r,- r, 0]) cylinder(h,r,r);
    }
}


module roundinside(){
    union(){
         difference(){
              inside();
                  translate([0,0])round(8,0);
                  translate([43,0])round(8,1);
                  translate([43,43])round(8,2);
                  translate([0,43])round(8,3);
                  translate([48,30])round(4,2);
                  translate([48,13])round(4,1);
         }
      translate([43,30])round(1.5,0);
      translate([43,13])round(1.5,3);
}  
}

module outside(){
offset(1.5) roundinside();
}

module wall(){
    difference(){
        outside();
            roundinside();
    }
}

$fn=80;

difference(){
    union(){
        linear_extrude(10) wall();
        translate ([-8,17,0])cube([8,10,10]);
        translate ([-1.5,17,0])fillet(1.2,10);  
        translate ([-1.5,27,0])fillet(1.2,10);    
     }
    translate([-4.5, 10,5]) rotate ([-90,0,0]) cylinder (20,1.5,1.5);
    translate([-20,22,0])cube([20,1,20]);
    translate([-8,0,0])rotate([-90,0,0])fillet(3,50);
    translate([-8,0,10])rotate([-90,0,0])fillet(3,50);


On Tue, Mar 2, 2021 at 7:59 AM Ray West <[hidden email]> wrote:

In the user manual it mentions - TIP: If you want to create a circle/cylinder/sphere which has an axis aligned integer bounding box (i.e. a bounding box that has integral dimensions, and an integral position) use a value of $fn that is divisible by 4.

In my recent creation, I'v found, for the first time, that there are a number of $fn which do not allow the model to be rendered. Values such as 20, 24, 40, 100 and many other fail, but 25, 50, 75 are OK.

80 fails, 81 is OK, etc. Is this behaviour expected, I've not found it happening before, but  I'm not a heavy user? If it is normal, then it is not a problem to me, providedIi expect it to occur. The object has a number of curved surfaces - I've been rounding off corners.




module inside(){
 polygon(points=[[0,0],[0,43],[43,43],[43,30],[48,30],[48,13],[43,13],[43,0]]);
}


module round(r){
   difference(){
       square(2*r+0.001,true);
          translate([r,r]) circle(r);
          translate([-r,r]) circle(r);
          translate([r,-r]) circle(r);
          translate([-r,-r]) circle(r);
   }
}


module fillet(r,h){
       difference() {
           translate([0,0,h/2]) cube([2*r + 0.001, 2*r + 0.001, h], center = true);
               translate([r, r, 0]) cylinder(h,r,r);
               translate([-r, r, 0]) cylinder(h,r,r);
               translate([-r, -r, 0]) cylinder(h,r,r);
               translate([r,- r, 0]) cylinder(h,r,r);
    }
}


module roundinside(){
    union(){
         difference(){
              inside();
                  translate([0,0])round(8);
                  translate([43,0])round(8);
                  translate([43,43])round(8);
                  translate([0,43])round(8);
                  translate([48,30])round(4);
                  translate([48,13])round(4); 
         }
      translate([43,30])round(1.5);
      translate([43,13])round(1.5); 
}  
}


module outside(){
offset(1.5) roundinside();
}


module wall(){
    difference(){
        outside();
            roundinside();
    }
}

$fn=81;

difference(){
    union(){
        linear_extrude(10)wall();
        translate ([-8,17,0])cube([8,10,10]);
        translate ([-1.5,17,0])fillet(1.2,10);   
        translate ([-1.5,27,0])fillet(1.2,10);    
     }
    translate([-4.5, 10,5]) rotate ([-90,0,0])cylinder (20,1.5,1.5);
    translate([-20,22,0])cube([20,1,20]);
    translate([-8,0,0])rotate([-90,0,0])fillet(3,50);
    translate([-8,0,10])rotate([-90,0,0])fillet(3,50);
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

cacb
In reply to this post by mondo
On 02.03.2021 14:59, Ray West wrote:
> In the user manual it mentions - *TIP:* If you want to create a
> circle/cylinder/sphere which has an axis aligned integer bounding box
> (i.e. a bounding box that has integral dimensions, and an integral
> position) use a value of $fn that is divisible by 4.
>
> In my recent creation, I'v found, for the first time, that there are a
> number of $fn which do not allow the model to be rendered. Values such
> as 20, 24, 40, 100 and many other fail, but 25, 50, 75 are OK.

Creating "circles" with discrete number of sides is in my opinion not
the best idea. I would have extruded polygons for this purpose since you
then create the required geometry explicitly. I think geometry
specification and mesh discretization is best considered different things.

In AngelCAD you can easily create a polygon from a radius and n sides
and create a "cylinder" by extrusion:

        linear_extrude(polygon(r:100,np:8),100);


this is equivalent to OpenSCAD

        linear_extrude(100) {
      circle(100,$fn=8);
        }


Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

poly.png (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

Ronaldo
In reply to this post by thehans

Em ter., 2 de mar. de 2021 às 14:29, Hans L <[hidden email]> escreveu:
The circles in your "round" module are touching at single points, which is not manifold.

That doesn't explain everything. To simplify let us take the following definition of fillet() which is equivalent to the original:

module fillet(r,h){
    linear_extrude(h,convexity=4) round(r);
}

If we view the preview fillet(1.2,10) from the top with edges on and $fn=80 we get: 
wisker80.PNG
So, the very tip of the fillet() base is formed by a reasonably fat triangle and that should not be considered a non-manifold. However it is rejected by F6 with an unusual error message when two disjoint fillets are unioned with:

    union(){
     //   linear_extrude(10,convexity=10)wall();
     //   translate ([-8,17,0])cube([8,10,10]);
        translate ([-1.5,17,0])fillet(1.2,10);  
        translate ([-1.5,27,0])fillet(1.2,10);    
     }

BTW, the error message of F6 is not the usual non-manifold warning but rather:


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

mondo
In reply to this post by thehans
Thanks for the replies, Although I could make a satisfactory print, i
was curious as to why, depending on the $fn value, it would often not
render. Thanks, Hans, for showing me the error of my ways. I very rarely
use openscad by extruding 2d, normally I use 3d solids, merely
adding/subtracting parts as required. Thanks for identifying the
problem, and correcting my code. I derived the 2d 'round', based on my
3d version ('fillet' in my code) which seems to give no problems for any
$fn value that I've tried. If  I alter my 'round' code, so the circles
do not touch, then hopefully that will work too. I was curious if there
was some reason, similar to the 'tip' in the document, explaining which
values of $fn were valid. It seems, that if it is not manifold, then
anything can happen.

On 02/03/2021 14:28, Hans L wrote:
> The circles in your "round" module are touching at single
> points, which is not manifold.
>
> If you modify it to only round one corner at a time, and rotate
> appropriately at each position, then  it works fine.
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

Ronaldo
In reply to this post by Ronaldo
A further investigation shows that the original fillet() and round() modules produce in fact non manifolds, not because the circles and cylinders are touching but because the square (in round()) and the cube (in fillet()) are a bit bigger than they should be. Ray West's model works fine and render successfully with the redefinitions:

module round(r){
   difference(){
       square(2*r /* + 0.001 */,true);
          translate([r,r]) circle(r);
          translate([-r,r]) circle(r);
          translate([r,-r]) circle(r);
          translate([-r,-r]) circle(r);
   }
}

module fillet(r,h){
       difference() {
           translate([0,0,h/2]) cube([2*r /* + 0.001 */ , 2*r  /* + 0.001 */ , h], center = true);
               translate([r, r, 0]) cylinder(h,r,r);
               translate([-r, r, 0]) cylinder(h,r,r);
               translate([-r, -r, 0]) cylinder(h,r,r);
               translate([r,- r, 0]) cylinder(h,r,r);
    }
}

With the redefinition of fillet() in my previous message I have solved part of the trouble but round() was kept as the original and the non-manifoldness was still present.


Em ter., 2 de mar. de 2021 às 17:59, Ronaldo Persiano <[hidden email]> escreveu:

Em ter., 2 de mar. de 2021 às 14:29, Hans L <[hidden email]> escreveu:
The circles in your "round" module are touching at single points, which is not manifold.

That doesn't explain everything. To simplify let us take the following definition of fillet() which is equivalent to the original:

module fillet(r,h){
    linear_extrude(h,convexity=4) round(r);
}

If we view the preview fillet(1.2,10) from the top with edges on and $fn=80 we get: 
wisker80.PNG
So, the very tip of the fillet() base is formed by a reasonably fat triangle and that should not be considered a non-manifold. However it is rejected by F6 with an unusual error message when two disjoint fillets are unioned with:

    union(){
     //   linear_extrude(10,convexity=10)wall();
     //   translate ([-8,17,0])cube([8,10,10]);
        translate ([-1.5,17,0])fillet(1.2,10);  
        translate ([-1.5,27,0])fillet(1.2,10);    
     }

BTW, the error message of F6 is not the usual non-manifold warning but rather:


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $fn behaviour

mondo
In reply to this post by mondo
For the sake of completeness,

Here's my modified round module, gives no errors -

module round(r){
    difference(){
        square(2*r,true);
           translate([r+0.001,r+0.001]) circle(r);
           translate([-r-0.001,r-0.001]) circle(r);
           translate([r+0.001,-r-0.001]) circle(r);
           translate([-r-0.001,-r-0.001]) circle(r);
    }
}

On 02/03/2021 18:36, Ray West wrote:

> Thanks for the replies, Although I could make a satisfactory print, i
> was curious as to why, depending on the $fn value, it would often not
> render. Thanks, Hans, for showing me the error of my ways. I very
> rarely use openscad by extruding 2d, normally I use 3d solids, merely
> adding/subtracting parts as required. Thanks for identifying the
> problem, and correcting my code. I derived the 2d 'round', based on my
> 3d version ('fillet' in my code) which seems to give no problems for
> any $fn value that I've tried. If  I alter my 'round' code, so the
> circles do not touch, then hopefully that will work too. I was curious
> if there was some reason, similar to the 'tip' in the document,
> explaining which values of $fn were valid. It seems, that if it is not
> manifold, then anything can happen.
>
> On 02/03/2021 14:28, Hans L wrote:
>> The circles in your "round" module are touching at single
>> points, which is not manifold.
>>
>> If you modify it to only round one corner at a time, and rotate
>> appropriately at each position, then  it works fine.
>>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org