discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

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

T
Troberg
Thu, Dec 24, 2020 6:35 PM

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/

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/
NH
nop head
Thu, Dec 24, 2020 6:49 PM

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

[image: 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 troberg.anders@gmail.com 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I think because the resulting shape is non-manifold because the two remaining cubes share an edge. F6 gives this. [image: 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 <troberg.anders@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Thu, Dec 24, 2020 6:54 PM

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 nop.head@gmail.com wrote:

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

[image: 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 troberg.anders@gmail.com 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <nop.head@gmail.com> wrote: > I think because the resulting shape is non-manifold because the two > remaining cubes share an edge. F6 gives this. > > [image: 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 <troberg.anders@gmail.com> 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 >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
T
Troberg
Thu, Dec 24, 2020 7:59 PM

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/

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/
NH
nop head
Thu, Dec 24, 2020 8:05 PM

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

On Thu, 24 Dec 2020 at 20:00, Troberg troberg.anders@gmail.com 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

The 2D one could just offset the intersection by eps I think. On Thu, 24 Dec 2020 at 20:00, Troberg <troberg.anders@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >