Why does this work in 2D, but not in 3D?

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

Why does this work in 2D, but not in 3D?

Troberg
This code works as expected in 2D (except for some surfaces sharing the same
plane, but we can ignore that for now), but not in 3D. I can't see why it
shouldn't work, and when I pick it apart, each step works, but when it do it
all, it does not behave as expected.

module xor(){
        difference(){
                union(){
                        children();
                }
               
                intersection(){
                        children(0);
                       
                        children(1);
                }
        }
}

translate([30,0,0]) //2D
xor(){
        square([20,10]);
        square([10,20]);
}

xor(){ //3D, should just be a thicker variant of the 2D result
        cube([20,10,10]);
        cube([10,20,10]);
}

Am I missing something stupid here?



--
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: Why does this work in 2D, but not in 3D?

nophead
I think because the resulting shape is non-manifold because the two remaining cubes share an edge. F6 gives this.

image.png

Top level object is a 3D object:

Simple: no

Vertices: 14

Halfedges: 46

Edges: 23

Halffacets: 24

Facets: 12

Volumes: 3

UI-WARNING: Object may not be a valid 2-manifold and may need repair!



On Thu, 24 Dec 2020 at 18:36, Troberg <[hidden email]> wrote:
This code works as expected in 2D (except for some surfaces sharing the same
plane, but we can ignore that for now), but not in 3D. I can't see why it
shouldn't work, and when I pick it apart, each step works, but when it do it
all, it does not behave as expected.

module xor(){
        difference(){
                union(){
                        children();
                }

                intersection(){
                        children(0);

                        children(1);
                }
        }
}

translate([30,0,0]) //2D
xor(){
        square([20,10]);
        square([10,20]);
}

xor(){ //3D, should just be a thicker variant of the 2D result
        cube([20,10,10]);
        cube([10,20,10]);
}

Am I missing something stupid here?



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

_______________________________________________
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: Why does this work in 2D, but not in 3D?

nophead
This bodge works.

eps = 1/1024;
module xor(){
        difference(){
                union(){
                        children();
                }
                translate([-eps, -eps, , -eps])
                    scale(1 + 2 * eps)
                        intersection(){
                                children(0);

                                children(1);
                        }
        }
}


On Thu, 24 Dec 2020 at 18:49, nop head <[hidden email]> wrote:
I think because the resulting shape is non-manifold because the two remaining cubes share an edge. F6 gives this.

image.png

Top level object is a 3D object:

Simple: no

Vertices: 14

Halfedges: 46

Edges: 23

Halffacets: 24

Facets: 12

Volumes: 3

UI-WARNING: Object may not be a valid 2-manifold and may need repair!



On Thu, 24 Dec 2020 at 18:36, Troberg <[hidden email]> wrote:
This code works as expected in 2D (except for some surfaces sharing the same
plane, but we can ignore that for now), but not in 3D. I can't see why it
shouldn't work, and when I pick it apart, each step works, but when it do it
all, it does not behave as expected.

module xor(){
        difference(){
                union(){
                        children();
                }

                intersection(){
                        children(0);

                        children(1);
                }
        }
}

translate([30,0,0]) //2D
xor(){
        square([20,10]);
        square([10,20]);
}

xor(){ //3D, should just be a thicker variant of the 2D result
        cube([20,10,10]);
        cube([10,20,10]);
}

Am I missing something stupid here?



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

_______________________________________________
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: Why does this work in 2D, but not in 3D?

Troberg
nophead wrote
> This bodge works.

Except that 2D stops working, but that's because you can't scale Z in 2D.

I suppose I'll have to make a 2dxor and a 3dxor.

Thanks!



--
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: Why does this work in 2D, but not in 3D?

nophead
The 2D one could just offset the intersection by eps I think.


On Thu, 24 Dec 2020 at 20:00, Troberg <[hidden email]> wrote:
nophead wrote
> This bodge works.

Except that 2D stops working, but that's because you can't scale Z in 2D.

I suppose I'll have to make a 2dxor and a 3dxor.

Thanks!



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

_______________________________________________
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