discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

polyhedron rendering

JB
Jordan Brown
Fri, Dec 23, 2022 7:28 PM

On 12/23/2022 11:08 AM, jay@jdnd.co.uk wrote:

this works fine

//tol = 2;
tol = 0.001;
tol2 = tol*2;

//difference()
{
    size = 3;
    angle = 10;
    
    color("red")
    cube([size, size, size]);
    
    color("blue")
    translate([0-tol, (size/2)-tol, -tol])
    rotate([0, 0, angle])
    cube([size2, size2, size+tol2]);
}

Playing with color is indeed problematic, and you may need thin "paint"
layers or slightly-oversized components.

The commented-out difference confuses the issue a little.  If you're
really thinking of a difference, then usually there's no issue with how
big "tol" is.  The only would-be-coincident faces are the top and bottom
of the red cube at the +Y end where it overlaps with the blue cube. 
Adding "tol" to the X and Y positions will indeed cause problems, but
you don't need it there; you only need it in Z... and if you're
differencing, it doesn't matter how tall the blue cube is; you'll get
the same results (modulo the camera position artifacts also mentioned)
if the blue cube is 0.001 oversized as if it's 100 oversized.

tol = 0;
//tol = 0.001;
//tol = 100;
tol2 = tol*2;

difference()
{
size = 3;
angle = 10;

color("red")
cube([size, size, size]);

color("blue")
translate([0, (size/2), -tol])
    rotate([0, 0, angle])
    cube([size*2, size*2, size+tol2]);

}

tol=0, bad:

tol=0.001:

tol=100:

On 12/23/2022 11:08 AM, jay@jdnd.co.uk wrote: > this works fine > > //tol = 2; > tol = 0.001; > tol2 = tol*2; > > //difference() > { >     size = 3; >     angle = 10; >      >     color("red") >     cube([size, size, size]); >      >     color("blue") >     translate([0-tol, (size/2)-tol, -tol]) >     rotate([0, 0, angle]) >     cube([size*2, size*2, size+tol2]); > } > Playing with color is indeed problematic, and you may need thin "paint" layers or slightly-oversized components. The commented-out difference confuses the issue a little.  If you're really thinking of a difference, then usually there's no issue with how big "tol" is.  The only would-be-coincident faces are the top and bottom of the red cube at the +Y end where it overlaps with the blue cube.  Adding "tol" to the X and Y positions will indeed cause problems, but you don't *need* it there; you only need it in Z... and if you're differencing, it doesn't matter how tall the blue cube is; you'll get the same results (modulo the camera position artifacts also mentioned) if the blue cube is 0.001 oversized as if it's 100 oversized. tol = 0; //tol = 0.001; //tol = 100; tol2 = tol*2; difference() { size = 3; angle = 10; color("red") cube([size, size, size]); color("blue") translate([0, (size/2), -tol]) rotate([0, 0, angle]) cube([size*2, size*2, size+tol2]); } tol=0, bad: tol=0.001: tol=100:
AM
Adrian Mariano
Fri, Dec 23, 2022 10:48 PM

Really the problem with the original code is the translate() that moves the
cube by the tolerance.  This results in the cube "expanding" by the
tolerance in the wrong direction.  You need to ensure that you make models
oversized where you need oversize and make them exact where that is
appropriate.

On Fri, Dec 23, 2022 at 2:29 PM Jordan Brown openscad@jordan.maileater.net
wrote:

On 12/23/2022 11:08 AM, jay@jdnd.co.uk wrote:

this works fine

//tol = 2;
tol = 0.001;
tol2 = tol*2;

//difference()
{
size = 3;
angle = 10;

 color("red")
 cube([size, size, size]);

 color("blue")
 translate([0-tol, (size/2)-tol, -tol])
 rotate([0, 0, angle])
 cube([size*2, size*2, size+tol2]);

}

Playing with color is indeed problematic, and you may need thin "paint"
layers or slightly-oversized components.

The commented-out difference confuses the issue a little.  If you're
really thinking of a difference, then usually there's no issue with how big
"tol" is.  The only would-be-coincident faces are the top and bottom of the
red cube at the +Y end where it overlaps with the blue cube.  Adding "tol"
to the X and Y positions will indeed cause problems, but you don't need
it there; you only need it in Z... and if you're differencing, it doesn't
matter how tall the blue cube is; you'll get the same results (modulo the
camera position artifacts also mentioned) if the blue cube is 0.001
oversized as if it's 100 oversized.

tol = 0;
//tol = 0.001;
//tol = 100;
tol2 = tol*2;

difference()
{
size = 3;
angle = 10;

 color("red")
 cube([size, size, size]);

 color("blue")
 translate([0, (size/2), -tol])
     rotate([0, 0, angle])
     cube([size*2, size*2, size+tol2]);

}

tol=0, bad:

tol=0.001:

tol=100:


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Really the problem with the original code is the translate() that moves the cube by the tolerance. This results in the cube "expanding" by the tolerance in the wrong direction. You need to ensure that you make models oversized where you need oversize and make them exact where that is appropriate. On Fri, Dec 23, 2022 at 2:29 PM Jordan Brown <openscad@jordan.maileater.net> wrote: > On 12/23/2022 11:08 AM, jay@jdnd.co.uk wrote: > > this works fine > > //tol = 2; > tol = 0.001; > tol2 = tol*2; > > //difference() > { > size = 3; > angle = 10; > > color("red") > cube([size, size, size]); > > color("blue") > translate([0-tol, (size/2)-tol, -tol]) > rotate([0, 0, angle]) > cube([size*2, size*2, size+tol2]); > } > > > Playing with color is indeed problematic, and you may need thin "paint" > layers or slightly-oversized components. > > The commented-out difference confuses the issue a little. If you're > really thinking of a difference, then usually there's no issue with how big > "tol" is. The only would-be-coincident faces are the top and bottom of the > red cube at the +Y end where it overlaps with the blue cube. Adding "tol" > to the X and Y positions will indeed cause problems, but you don't *need* > it there; you only need it in Z... and if you're differencing, it doesn't > matter how tall the blue cube is; you'll get the same results (modulo the > camera position artifacts also mentioned) if the blue cube is 0.001 > oversized as if it's 100 oversized. > > tol = 0; > //tol = 0.001; > //tol = 100; > tol2 = tol*2; > > difference() > { > size = 3; > angle = 10; > > color("red") > cube([size, size, size]); > > color("blue") > translate([0, (size/2), -tol]) > rotate([0, 0, angle]) > cube([size*2, size*2, size+tol2]); > } > > > tol=0, bad: > > > > tol=0.001: > > tol=100: > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >