Wish: explicitly negative volume components

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

Wish: explicitly negative volume components

Piotr Wyderski
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

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

Re: Wish: explicitly negative volume components

Ronaldo
To be well defined, it is necessary to know what results from composing the operator negative() with other operators besides union() like:

intersection() {A() ; negative() B() ;}

difference() {negative() A() ; B() ; negative() C() ;} 

and what would be rendered for each:

negative() cube() ;

negative() difference() {cube() ; cube()} 



Em 15 de out de 2017 06:59, "Piotr Wyderski" <[hidden email]> escreveu:
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

_______________________________________________
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: Wish: explicitly negative volume components

KarijnWessing
In reply to this post by Piotr Wyderski
You can make a module that operates on it's childeren

module makePin()
{
    union()
    {
        difference()
        {
            // here the magic happens:
            union(){ children(); }
           
            cube([5, 3, 10], center=true);
            cube([3, 5, 10], center=true);
        }
        cube([5, 1, 1], center=true);
        cube([1, 5, 1], center=true);
    }
}
// subtract a cross from the cube and add soething into it
//
makePin() cube([10, 10, 1], center=true);




--
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: Wish: explicitly negative volume components

doug.moen
In reply to this post by Piotr Wyderski
The Relativity library already has support for negative volumes.

You would do this by tagging negative volumes with the class name "negative" (or any name you want), then subtract the negative shapes from the model at the top level.

Issue #1608 discusses a proposal for adding a similar feature to OpenSCAD in a general way (the terminology used here is "part names" rather than "class names".

On 15 October 2017 at 04:58, Piotr Wyderski <[hidden email]> wrote:
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

_______________________________________________
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: Wish: explicitly negative volume components

Gadgetmind
In reply to this post by Piotr Wyderski
On 2017-10-15 09:58, Piotr Wyderski wrote:
> That is, one cannot return from a module
> a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default,
so the module creates its positive objects, and the module is then
called again from difference () with flag set to let it subtract its
negative spaces.

OK, so a bit messy, but it does give the localisation of positive and
negative into the same module and lots of transformations can be shared.


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

Re: Wish: explicitly negative volume components

nophead
I just factor the positioning transformations so that they can be shared.

I do complex assemblies that join and make mounting holes, etc without any desire for negative volumes or named attachments.

On 16 October 2017 at 12:01, Gadgetmind <[hidden email]> wrote:
On 2017-10-15 09:58, Piotr Wyderski wrote:
That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default, so the module creates its positive objects, and the module is then called again from difference () with flag set to let it subtract its negative spaces.

OK, so a bit messy, but it does give the localisation of positive and negative into the same module and lots of transformations can be shared.


_______________________________________________
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: Wish: explicitly negative volume components

Piotr Wyderski
Agreed, you can do all that transformations manually, but you just
shouldn't: it is the task of a machine, not a human. A human should
be provided with a set of convenient tools to create models efficiently
and correctly. After several days of using OpenSCAD I was able to
identify two of them, hence the wish list posts. I have modelled the
parts correctly and then suddenly discovered that there are no tools
to compose them into a higher-order entity.

    Best regards, Piotr


2017-10-16 13:53 GMT+02:00 nop head <[hidden email]>:
I just factor the positioning transformations so that they can be shared.

I do complex assemblies that join and make mounting holes, etc without any desire for negative volumes or named attachments.

On 16 October 2017 at 12:01, Gadgetmind <[hidden email]> wrote:
On 2017-10-15 09:58, Piotr Wyderski wrote:
That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default, so the module creates its positive objects, and the module is then called again from difference () with flag set to let it subtract its negative spaces.

OK, so a bit messy, but it does give the localisation of positive and negative into the same module and lots of transformations can be shared.


_______________________________________________
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



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

Re: Wish: explicitly negative volume components

Troberg
In reply to this post by Ronaldo
This just gave me an idea. When doing odd shapes, hull is good for doing
convex corners, but not as good for concave corners.

With negative objects, this could be solved. Where a positive object
"stretches the surface" outside it, the negative object would instead
stretch it so that the object is outside the resulting object.

So, for example, a boomerang could be modelled (and I'm simplifying things
here, the actual viability of the boomerang is not the point) as the hull of
three short, wide cylinders in a triangle, and a negative cylinder in the
"V".

Of course, for this to work, the order of the objects needs to be taken into
account.

Would be very useful in making softer, more organic shapes.

Still, has some problems which needs to be sorted out, of course. I'm just
planting ideas...



--
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: Wish: explicitly negative volume components

nophead
Yes I proposed a concave_hull() operator a while ago. It would be like difference where the first object is positive and the rest are negative.

On 7 December 2017 at 09:50, Troberg <[hidden email]> wrote:
This just gave me an idea. When doing odd shapes, hull is good for doing
convex corners, but not as good for concave corners.

With negative objects, this could be solved. Where a positive object
"stretches the surface" outside it, the negative object would instead
stretch it so that the object is outside the resulting object.

So, for example, a boomerang could be modelled (and I'm simplifying things
here, the actual viability of the boomerang is not the point) as the hull of
three short, wide cylinders in a triangle, and a negative cylinder in the
"V".

Of course, for this to work, the order of the objects needs to be taken into
account.

Would be very useful in making softer, more organic shapes.

Still, has some problems which needs to be sorted out, of course. I'm just
planting ideas...



--
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: Wish: explicitly negative volume components

Parkinbot
In reply to this post by Piotr Wyderski
Piotr Wyderski wrote

> The real power comes from the ability to combine both positive and
> negative
> volumes within a single module.
>
> module ball_hole() {
>
>    union { negative() sphere(r=1, center=true);
>                cube(0.1, center=true);
>    }
> }

I would say, the real power comes from using the appropriate Boolean
operation:


> module ball_hole()
>    difference { cube(0.1, center=true); sphere(r=1, center=true);  }

A negative object will exend to infinite. It can't be rendered and will
obviously create a bag full of problems if used as operand in the Boolean
operations difference() and union(), while just intersection is save.
Where is the problem in using a difference() operation, which was indeed
introduced to get along *without* negation?  





--
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: Wish: explicitly negative volume components

Piotr Wyderski
> Where is the problem in using a difference() operation, which was indeed
> introduced to get along *without* negation?

There is absolutely no problem, especially since I stopped using OpenSCAD.

    Best regards,
    Piotr Wyderski

2017-12-08 18:00 GMT+01:00 Parkinbot <[hidden email]>:
Piotr Wyderski wrote
> The real power comes from the ability to combine both positive and
> negative
> volumes within a single module.
>
> module ball_hole() {
>
>    union { negative() sphere(r=1, center=true);
>                cube(0.1, center=true);
>    }
> }

I would say, the real power comes from using the appropriate Boolean
operation:


> module ball_hole()
>    difference { cube(0.1, center=true); sphere(r=1, center=true);  }

A negative object will exend to infinite. It can't be rendered and will
obviously create a bag full of problems if used as operand in the Boolean
operations difference() and union(), while just intersection is save.
Where is the problem in using a difference() operation, which was indeed
introduced to get along *without* negation?





--
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: Wish: explicitly negative volume components

doug.moen
Piotr, what are you using instead of openscad?

On Sunday, 10 December 2017, Piotr Wyderski <[hidden email]> wrote:
> Where is the problem in using a difference() operation, which was indeed
> introduced to get along *without* negation?

There is absolutely no problem, especially since I stopped using OpenSCAD.

    Best regards,
    Piotr Wyderski

2017-12-08 18:00 GMT+01:00 Parkinbot <[hidden email]>:
Piotr Wyderski wrote
> The real power comes from the ability to combine both positive and
> negative
> volumes within a single module.
>
> module ball_hole() {
>
>    union { negative() sphere(r=1, center=true);
>                cube(0.1, center=true);
>    }
> }

I would say, the real power comes from using the appropriate Boolean
operation:


> module ball_hole()
>    difference { cube(0.1, center=true); sphere(r=1, center=true);  }

A negative object will exend to infinite. It can't be rendered and will
obviously create a bag full of problems if used as operand in the Boolean
operations difference() and union(), while just intersection is save.
Where is the problem in using a difference() operation, which was indeed
introduced to get along *without* negation?





--
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