Welcome! Log In Create A New Profile

Advanced

Feature request

Posted by appjaws1 
Feature request
January 16, 2017 07:55AM
In another thread it was highlighted that Minkowski difference is not implemented in openscad.
So how do we request a feature be added to openscad?


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: Feature request
January 22, 2017 04:21PM
I'd like this too... and Minkowski intersection (i.e. a shell). smiling smiley Actually, it might be better if minkowski() was modified to not automatically union() the original object into the result. Perhaps by passing an optional parameter to it?

I think the following implements Minkowski difference (if I understand correctly what that is). Or are there subtleties I've missed?


// Minkowski difference??? of a given object with second given object, similar to the existing minkowski() function.

module minkowskiDifference() {
        difference() {
            children(0);
            minkowski() {
                children(0);
                children(1);
            }
        }
 }    

// Shell of a given object with second given object, similar to the existing minkowski() function.
module minkowskiIntersection() {
        intersection() {
            minkowskiDifference() {
                children(0);
                children(1)
            }
            children(0);
        }
 }

Both these modules are off-the-cuff and untested!
Re: Feature request
January 23, 2017 07:05AM
Thank you frankvdh,

I think I might be using this the wrong way because I keep getting children index (0) out of bounds

As an example I am trying to do something similar to

$fn=50;
minkowski()
{
cube([10,10,4]);
cylinder(r=2,h=4);
}

with a minkowski()
{
cube([8,8,2]);
cylinder(r=2,h=2);
}
removed, leaving a hollow rounded corners cube with 1mm walls.

I think my problem is that I don't understand the children help section

Is it possible for you to provide an example based on your solution for minkowskiDifference()


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: Feature request
January 23, 2017 03:59PM
My apologies, I had the difference() children back to front.... here's something that does work:


module minkowskiDifference() {
    difference() {
         minkowski() {
            children(0);
            children(1);
        }
        children(0);
   }
 }    

intersection() {  // To show that the minkowski difference is hollow inside
    minkowskiDifference() {
        cube([5, 4, 10]);
        sphere(1, center=true);
    }
    cube([5,4,10], center=true);
}

Re: Feature request
January 25, 2017 11:19PM
Great, thank you.


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: Feature request
January 26, 2017 08:35AM
Quote
frankvdh
I think the following implements Minkowski difference (if I understand correctly what that is). Or are there subtleties I've missed?

I had understood the Minkowski difference the other way round, i.e. not to subtract the original object from the Minkowski sum (which indeed is easy), but rather to subtract the second object from all points on the surface of the first object. So the result would not be a hollow object, but a smaller version of the first object from which the second object was "shaved away" on all sides.
Re: Feature request
January 26, 2017 09:49AM
Further to this discussion, I rethought about this problem - and I think that I found a solution...

My implementation uses the fact that the Minkowski sum acts as a difference when applied to a cavity inside a larger object.
So we need to construct an object which has a "hole" that corresponds to the original object and apply the Minkowski sum to make the hole smaller using the second object. Then the Minkowski difference is obtain by a (standard) difference subtracting the resulting hollow object from the initial object:
////////////////////////////////////////////////////////////////////
// Implementation of a Minkowski difference using
// the Minkowski sum on a negative ("hole") of the initial object
////////////////////////////////////////////////////////////////////
module minkdiff(){
   // Subtract from the original object a bigger object with a Minkowski summed (->reduced) hole
   difference(){
      children(0);
         // Minkowski sum of the negative initial object 
         minkowski(){
            // make a hollow object with a hole that corresponds to the initial object
            difference(){
               // increase the size of initial object using Minkowski sum
               minkowski(){
                  children(0);
                  cube([1,1,1],true);
               }
               // now remove initial object
               children(0);
            }
            children(1);
         }
      }
   } 


// now try it out, to see if it works...

%cylinder(r=10,h=10);
%color("red",0.5)translate([-10,0,10])cube([10,1,1],true);
minkdiff(){
   cylinder(r=10,h=10);
   cube([10,1,1],true);
}

Here is the result of the above example: the Minkowski difference (green) of a cylinder (gray) with a cube (red).



I am not sure how robust this implementation is for really complex object - but so far, it's the best solution I could come up with...

Edited 1 time(s). Last edit at 01/26/2017 09:58AM by enif.
Sorry, only registered users may post in this forum.

Click here to login