discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

The behaviour if intersection has changed.

NH
nop head
Fri, Oct 2, 2020 10:37 AM

Intersection with only one argument returns that argument. Previously a
second argument guarded by a false if was ignored but with the latest
snapshot it seems to be counted as and empty argument giving an empty
result.

intersection() {
cube();

if(false)
    sphere();

}

I.e. this gives a cube with the last release but the latest snapshot gives
nothing. Again this has broken my library as I made use of it. For example
this code:

module shape()
    intersection() {
        hull() {
            circle(boss_r);

            translate([boss_r + extension - eps, 0])
                square([eps, 2 * boss_r], center = true);
        }
        if(corner_r)
            translate([boss_r + extension - corner_r, 0])
                rotate(-45)
                    quadrant(w = 100, r = corner_r - eps, center =

true);
}

Now has to be written like this:
module shape() {
module _shape()
hull() {
circle(boss_r);

            translate([boss_r + extension - eps, 0])
                square([eps, 2 * boss_r], center = true);
        }

    if(corner_r)
        intersection() {
            _shape();

            translate([boss_r + extension - corner_r, 0])
                rotate(-45)
                    quadrant(w = 100, r = corner_r - eps, center =

true);
}
else
_shape();
}

Again is this an intentional change? Should a false if be treated as
nothing at all or an empty object?

I do this a lot with difference but that still works because no second
argument is the same as an empty second argument with difference.

Intersection with only one argument returns that argument. Previously a second argument guarded by a false if was ignored but with the latest snapshot it seems to be counted as and empty argument giving an empty result. intersection() { cube(); if(false) sphere(); } I.e. this gives a cube with the last release but the latest snapshot gives nothing. Again this has broken my library as I made use of it. For example this code: module shape() intersection() { hull() { circle(boss_r); translate([boss_r + extension - eps, 0]) square([eps, 2 * boss_r], center = true); } if(corner_r) translate([boss_r + extension - corner_r, 0]) rotate(-45) quadrant(w = 100, r = corner_r - eps, center = true); } Now has to be written like this: module shape() { module _shape() hull() { circle(boss_r); translate([boss_r + extension - eps, 0]) square([eps, 2 * boss_r], center = true); } if(corner_r) intersection() { _shape(); translate([boss_r + extension - corner_r, 0]) rotate(-45) quadrant(w = 100, r = corner_r - eps, center = true); } else _shape(); } Again is this an intentional change? Should a false if be treated as nothing at all or an empty object? I do this a lot with difference but that still works because no second argument is the same as an empty second argument with difference.
TP
Torsten Paul
Fri, Oct 2, 2020 1:07 PM

On 02.10.20 12:37, nop head wrote:

Intersection with only one argument returns that argument.

Again is this an intentional change? Should a false if be
treated as nothing at all or an empty object?

So that's probably due to the fix for
https://github.com/openscad/openscad/issues/3312

I'm not sure there's a way to fix the bug and also keep the
behavior with if(false).

ciao,
Torsten.

On 02.10.20 12:37, nop head wrote: > Intersection with only one argument returns that argument. > Again is this an intentional change? Should a false if be > treated as nothing at all or an empty object? So that's probably due to the fix for https://github.com/openscad/openscad/issues/3312 I'm not sure there's a way to fix the bug and also keep the behavior with if(false). ciao, Torsten.
NH
nop head
Fri, Oct 2, 2020 1:17 PM

I think cube(0) and a non-overlapping intersection or any other csg
operation that results in an empty object is different from a false
if, which is no object at all.

On Fri, 2 Oct 2020 at 14:08, Torsten Paul Torsten.Paul@gmx.de wrote:

On 02.10.20 12:37, nop head wrote:

Intersection with only one argument returns that argument.

Again is this an intentional change? Should a false if be
treated as nothing at all or an empty object?

So that's probably due to the fix for
https://github.com/openscad/openscad/issues/3312

I'm not sure there's a way to fix the bug and also keep the
behavior with if(false).

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I think cube(0) and a non-overlapping intersection or any other csg operation that results in an empty object is different from a false if, which is no object at all. On Fri, 2 Oct 2020 at 14:08, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 02.10.20 12:37, nop head wrote: > > Intersection with only one argument returns that argument. > > > Again is this an intentional change? Should a false if be > > treated as nothing at all or an empty object? > > So that's probably due to the fix for > https://github.com/openscad/openscad/issues/3312 > > I'm not sure there's a way to fix the bug and also keep the > behavior with if(false). > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
TP
Torsten Paul
Fri, Oct 2, 2020 1:55 PM

On 02.10.20 15:17, nop head wrote:

I think cube(0) and a non-overlapping intersection or any
other csg operation that results in an empty object is
different from a false if, which is no object at all.

Right, it sounds sensible that if(false) would remove the
object completely. I guess we have to see if that would
affect anything where the if is used as first part of a
difference().

ciao,
Torsten.

On 02.10.20 15:17, nop head wrote: > I think cube(0) and a non-overlapping intersection or any > other csg operation that results in an empty object is > different from a false if, which is no object at all. Right, it sounds sensible that if(false) would remove the object completely. I guess we have to see if that would affect anything where the if is used as first part of a difference(). ciao, Torsten.
WW
William W Martin
Fri, Oct 2, 2020 3:33 PM

Is intersection not a logical AND operation? So what should you expect
if you say 1 AND 0 ?

On 10/2/20 6:07 AM, Torsten Paul wrote:

On 02.10.20 12:37, nop head wrote:

Intersection with only one argument returns that argument.
Again is this an intentional change? Should a false if be
treated as nothing at all or an empty object?

So that's probably due to the fix for
https://github.com/openscad/openscad/issues/3312

I'm not sure there's a way to fix the bug and also keep the
behavior with if(false).

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Is intersection not a logical AND operation? So what should you expect if you say 1 AND 0 ? On 10/2/20 6:07 AM, Torsten Paul wrote: > On 02.10.20 12:37, nop head wrote: >> Intersection with only one argument returns that argument. >> Again is this an intentional change? Should a false if be >> treated as nothing at all or an empty object? > So that's probably due to the fix for > https://github.com/openscad/openscad/issues/3312 > > I'm not sure there's a way to fix the bug and also keep the > behavior with if(false). > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Fri, Oct 2, 2020 3:45 PM

If the second operand is empty geometry I expect an empty result.

If the second object is missing I expect the first object, as it has always
done, just as difference() with one child. Intersection still does that.

What has changed is if(false) now produces an empty() node equivalent to
empty geometry, whereas before it returned an empty group() node, which
must have been ignored by intersection().

On Fri, 2 Oct 2020 at 16:33, William W Martin wwm@cox.net wrote:

Is intersection not a logical AND operation? So what should you expect
if you say 1 AND 0 ?

On 10/2/20 6:07 AM, Torsten Paul wrote:

On 02.10.20 12:37, nop head wrote:

Intersection with only one argument returns that argument.
Again is this an intentional change? Should a false if be
treated as nothing at all or an empty object?

So that's probably due to the fix for
https://github.com/openscad/openscad/issues/3312

I'm not sure there's a way to fix the bug and also keep the
behavior with if(false).

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If the second operand is empty geometry I expect an empty result. If the second object is missing I expect the first object, as it has always done, just as difference() with one child. Intersection still does that. What has changed is if(false) now produces an empty() node equivalent to empty geometry, whereas before it returned an empty group() node, which must have been ignored by intersection(). On Fri, 2 Oct 2020 at 16:33, William W Martin <wwm@cox.net> wrote: > Is intersection not a logical AND operation? So what should you expect > if you say 1 AND 0 ? > > > On 10/2/20 6:07 AM, Torsten Paul wrote: > > On 02.10.20 12:37, nop head wrote: > >> Intersection with only one argument returns that argument. > >> Again is this an intentional change? Should a false if be > >> treated as nothing at all or an empty object? > > So that's probably due to the fix for > > https://github.com/openscad/openscad/issues/3312 > > > > I'm not sure there's a way to fix the bug and also keep the > > behavior with if(false). > > > > ciao, > > Torsten. > > > > _______________________________________________ > > OpenSCAD mailing list > > Discuss@lists.openscad.org > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
TP
Torsten Paul
Fri, Oct 2, 2020 3:47 PM

On 02.10.20 17:33, William W Martin wrote:

Is intersection not a logical AND operation? So what
should you expect if you say 1 AND 0 ?

That's not the point, the question is if this:

intersection() {
cube();
if (false) sphere();
}

is equal to

intersection() {
cube();
}

=> result expectation is a cube

or

intersection() {
cube();
empty-geometry
}

=> result expectation is empty geometry

ciao,
Torsten.

On 02.10.20 17:33, William W Martin wrote: > Is intersection not a logical AND operation? So what > should you expect if you say 1 AND 0 ? That's not the point, the question is if this: intersection() { cube(); if (false) sphere(); } is equal to intersection() { cube(); } => result expectation is a cube or intersection() { cube(); *empty-geometry* } => result expectation is empty geometry ciao, Torsten.
WW
William W Martin
Fri, Oct 2, 2020 4:10 PM

On 10/2/20 8:47 AM, Torsten Paul wrote:

On 02.10.20 17:33, William W Martin wrote:

Is intersection not a logical AND operation? So what
should you expect if you say 1 AND 0 ?

That's not the point, the question is if this:

intersection() {
cube();
if (false) sphere();
}

is equal to

intersection() {
cube();
}

=> result expectation is a cube

or

intersection() {
cube();
empty-geometry
}

=> result expectation is empty geometry

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

All I am pointing out is that the "old" result has been wrong all along,
in spite of how many are used to it working that way. Something AND
nothing, no matter how you name "nothing", should always be nothing. Try
doing a VEN diagram...

regards,

Bill

On 10/2/20 8:47 AM, Torsten Paul wrote: > On 02.10.20 17:33, William W Martin wrote: >> Is intersection not a logical AND operation? So what >> should you expect if you say 1 AND 0 ? > That's not the point, the question is if this: > > intersection() { > cube(); > if (false) sphere(); > } > > is equal to > > intersection() { > cube(); > } > > => result expectation is a cube > > or > > intersection() { > cube(); > *empty-geometry* > } > > => result expectation is empty geometry > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > All I am pointing out is that the "old" result has been wrong all along, in spite of how many are used to it working that way. Something AND nothing, no matter how you name "nothing", should always be nothing. Try doing a VEN diagram... regards, Bill
A
arnholm@arnholm.org
Fri, Oct 2, 2020 4:13 PM

On 2020-10-02 17:45, nop head wrote:

What has changed is if(false) now produces an empty() node equivalent
to empty geometry, whereas before it returned an empty group() node,
which must have been ignored by intersection().

what is the significance between a "group()" node that is empty and an
"empty()" node that is empty?

One may also ask what is the significance between a "group()" that
contains something and a "union()" that contains something?

Carsten Arholm

On 2020-10-02 17:45, nop head wrote: > What has changed is if(false) now produces an empty() node equivalent > to empty geometry, whereas before it returned an empty group() node, > which must have been ignored by intersection(). what is the significance between a "group()" node that is empty and an "empty()" node that is empty? One may also ask what is the significance between a "group()" that contains something and a "union()" that contains something? Carsten Arholm
NH
nop head
Fri, Oct 2, 2020 4:13 PM

Yes an intersection between two operands works like that but what about an
intersection with one operand? There is no such thing in maths but the
OpenSCAD has had the convention of being a NOP in that case and so is union
and difference.

On Fri, 2 Oct 2020 at 17:11, William W Martin wwm@cox.net wrote:

On 10/2/20 8:47 AM, Torsten Paul wrote:

On 02.10.20 17:33, William W Martin wrote:

Is intersection not a logical AND operation? So what
should you expect if you say 1 AND 0 ?

That's not the point, the question is if this:

intersection() {
cube();
if (false) sphere();
}

is equal to

intersection() {
cube();
}

=> result expectation is a cube

or

intersection() {
cube();
empty-geometry
}

=> result expectation is empty geometry

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

All I am pointing out is that the "old" result has been wrong all along,
in spite of how many are used to it working that way. Something AND
nothing, no matter how you name "nothing", should always be nothing. Try
doing a VEN diagram...

regards,

Bill


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes an intersection between two operands works like that but what about an intersection with one operand? There is no such thing in maths but the OpenSCAD has had the convention of being a NOP in that case and so is union and difference. On Fri, 2 Oct 2020 at 17:11, William W Martin <wwm@cox.net> wrote: > > On 10/2/20 8:47 AM, Torsten Paul wrote: > > On 02.10.20 17:33, William W Martin wrote: > >> Is intersection not a logical AND operation? So what > >> should you expect if you say 1 AND 0 ? > > That's not the point, the question is if this: > > > > intersection() { > > cube(); > > if (false) sphere(); > > } > > > > is equal to > > > > intersection() { > > cube(); > > } > > > > => result expectation is a cube > > > > or > > > > intersection() { > > cube(); > > *empty-geometry* > > } > > > > => result expectation is empty geometry > > > > ciao, > > Torsten. > > > > _______________________________________________ > > OpenSCAD mailing list > > Discuss@lists.openscad.org > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > All I am pointing out is that the "old" result has been wrong all along, > in spite of how many are used to it working that way. Something AND > nothing, no matter how you name "nothing", should always be nothing. Try > doing a VEN diagram... > > regards, > > Bill > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >