Newbie Hull problem

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

Newbie Hull problem

MDFChris
Hi All

I've just started using OpenSCAD and so far I'm liking it, it suits my
engineering mind however I'm having an issue with a simple hull ?

I'm designing a nozzle for my 3D printer which seems simple enough using a
difference of two'd hull'd cubes:

//Nozzle
nozzle();
module nozzle(){
        difference(){
                port(1);
                port(0);
    }
}
module port(d){
        hull() {
                cube([19.5+d*2,15+d*2,2],center=true);
        translate([-10,4,15])
        rotate([0,-45,0])
        cube([7+d*2,14+d*2,2],center=true);
        }
}
however if I increase the rotation angle of the outlet port beyond -45 (i.e.
-50 or more) the open end starts to close up ?, I can't figure if I'm doing
something wrong or is this some sort of rounding error ?

Chris




--
Sent from: http://forum.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: Newbie Hull problem

JordanBrown
On 1/28/2018 11:46 AM, MDFChris wrote:
I've just started using OpenSCAD and so far I'm liking it, it suits my
engineering mind however I'm having an issue with a simple hull ?

I'm designing a nozzle for my 3D printer which seems simple enough using a
difference of two'd hull'd cubes:

//Nozzle
nozzle();
module nozzle(){
	difference(){
		port(1);
		port(0);
    }
}
module port(d){
	hull() {
		cube([19.5+d*2,15+d*2,2],center=true);
        translate([-10,4,15])
        rotate([0,-45,0])
        cube([7+d*2,14+d*2,2],center=true);
	}
}
however if I increase the rotation angle of the outlet port beyond -45 (i.e.
-50 or more) the open end starts to close up ?, I can't figure if I'm doing
something wrong or is this some sort of rounding error ?

It looks like your two top-end cubes have their top faces in the same place.  This causes an effect called Z-fighting, where the rendering program can't quite decide whether or not there's something there.  Note the shimmery yellow/green nature of that area; you don't want that.  At the higher angles it does indeed look like there's some kind of rounding area that is making part of the surface be "real" and infinitesimally thin.

The usual trick is, when you difference or intersect objects, to ensure that the objects protrude a bit so that they don't do that, so that the surface is cleanly removed or not-removed, e.g.:
    difference() {
        cube(10, center=true);
        cylinder(d=5, h=10.1, center=true);
    }
Here's a quick change that will make the effect go away in your model:
module port(d){
    hull() {
        fudge = d ? 0 : 0.1;
        cube([19.5+d*2,15+d*2,2 + fudge],center=true);
        translate([-10,4,15])
        rotate([0,-60,0])
        cube([7+d*2,14+d*2,2 + fudge],center=true);
    }
}

Note that you have the same issue on the bottom too, which is why I put in the fudge factor there too.

That 0.1 difference slightly changes the geometry of the model.  If that's important to you then you might need something more complex.



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

Re: Newbie Hull problem

JordanBrown
On 1/28/2018 12:14 PM, Jordan Brown wrote:
On 1/28/2018 11:46 AM, MDFChris wrote:
I've just started using OpenSCAD and so far I'm liking it, it suits my
engineering mind however I'm having an issue with a simple hull ?

I'm designing a nozzle for my 3D printer which seems simple enough using a
difference of two'd hull'd cubes:

//Nozzle
nozzle();
module nozzle(){
	difference(){
		port(1);
		port(0);
    }
}
module port(d){
	hull() {
		cube([19.5+d*2,15+d*2,2],center=true);
        translate([-10,4,15])
        rotate([0,-45,0])
        cube([7+d*2,14+d*2,2],center=true);
	}
}
however if I increase the rotation angle of the outlet port beyond -45 (i.e.
-50 or more) the open end starts to close up ?, I can't figure if I'm doing
something wrong or is this some sort of rounding error ?

It looks like your two top-end cubes have their top faces in the same place.  This causes an effect called Z-fighting, where the rendering program can't quite decide whether or not there's something there.  Note the shimmery yellow/green nature of that area; you don't want that.  At the higher angles it does indeed look like there's some kind of rounding area
Brain fart:  that should of course be "rounding error".
that is making part of the surface be "real" and infinitesimally thin.

The usual trick is, when you difference or intersect objects, to ensure that the objects protrude a bit so that they don't do that, so that the surface is cleanly removed or not-removed, e.g.:
    difference() {
        cube(10, center=true);
        cylinder(d=5, h=10.1, center=true);
    }
Here's a quick change that will make the effect go away in your model:
module port(d){
    hull() {
        fudge = d ? 0 : 0.1;
        cube([19.5+d*2,15+d*2,2 + fudge],center=true);
        translate([-10,4,15])
        rotate([0,-60,0])
        cube([7+d*2,14+d*2,2 + fudge],center=true);
    }
}

Note that you have the same issue on the bottom too, which is why I put in the fudge factor there too.

That 0.1 difference slightly changes the geometry of the model.  If that's important to you then you might need something more complex.




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

Re: Newbie Hull problem

atnbueno
In reply to this post by MDFChris
Hello Chris.

Other than the flicker of coincident faces, I have no problem going down to -90.

I've added a "scale(1.001)" before "port(0)" as a workaround for them and I get this with -90:
Imágenes integradas 1

2018-01-28 20:46 GMT+01:00 MDFChris <[hidden email]>:
Hi All

I've just started using OpenSCAD and so far I'm liking it, it suits my
engineering mind however I'm having an issue with a simple hull ?

I'm designing a nozzle for my 3D printer which seems simple enough using a
difference of two'd hull'd cubes:

//Nozzle
nozzle();
module nozzle(){
        difference(){
                port(1);
                port(0);
    }
}
module port(d){
        hull() {
                cube([19.5+d*2,15+d*2,2],center=true);
        translate([-10,4,15])
        rotate([0,-45,0])
        cube([7+d*2,14+d*2,2],center=true);
        }
}
however if I increase the rotation angle of the outlet port beyond -45 (i.e.
-50 or more) the open end starts to close up ?, I can't figure if I'm doing
something wrong or is this some sort of rounding error ?

Chris




--
Sent from: http://forum.openscad.org/

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



--
Saludos,
Antonio



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

Re: Newbie Hull problem

MDFChris
Thanks  for the fixes, glad it wasn't something I was doing wrong, I can
understand how what I'm asking has pushed the sums close to the edge !

Chris




--
Sent from: http://forum.openscad.org/

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