Minkowski rounings with Sphere

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

Minkowski rounings with Sphere

Snörre
Hello together,

the Minkowski function I think is to make a cube round, right?
So why is the radius added to the cube?
At least I work like this. I need a specific cube size with rounded edges.
Example:

I need a box with 100 x 60 x 20 with roundings 5.

In  the actual version I need to do:

minkowski()
{
  cube([90,50,10], center = true);
  sphere(r=5, $fn = 36);}

Or I do it with variables:

RoundingBox = 5;

minkowski()
{
  cube([100-RoundingBox*2,60-RoundingBox*2,20-RoundingBox*2], center =
true);
  sphere(r=5, $fn = 36);}


So, why not including the roundings directly into Minkowski?

Greetings




--
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: Minkowski rounings with Sphere

nophead
Because a Minkowski sum is a mathematical operation that sums two sets of points in all combinations to make a new set of points.

On Mon, 11 May 2020 at 13:28, Snörre <[hidden email]> wrote:
Hello together,

the Minkowski function I think is to make a cube round, right?
So why is the radius added to the cube?
At least I work like this. I need a specific cube size with rounded edges.
Example:

I need a box with 100 x 60 x 20 with roundings 5.

In  the actual version I need to do:

minkowski()
{
  cube([90,50,10], center = true);
  sphere(r=5, $fn = 36);}

Or I do it with variables:

RoundingBox = 5;

minkowski()
{
  cube([100-RoundingBox*2,60-RoundingBox*2,20-RoundingBox*2], center =
true);
  sphere(r=5, $fn = 36);}


So, why not including the roundings directly into Minkowski?

Greetings




--
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
rew
Reply | Threaded
Open this post in threaded view
|

Re: Minkowski rounings with Sphere

rew
On Mon, May 11, 2020 at 02:01:37PM +0100, nop head wrote:
> Because a Minkowski sum is a mathematical operation that sums two sets of
> points in all combinations to make a new set of points.
>
> On Mon, 11 May 2020 at 13:28, Snörre <[hidden email]> wrote:
>
> > Hello together,
> >
> > the Minkowski function I think is to make a cube round, right?

No. Minkowski is an operation that CAN be used to make a cube round.

Minkovsky does a UNION between ALL resulting objects when you
translate one object along a vector with the endpoint inside the
second object. This looks "asymmetric" but it isn't: the result is the
same whichever way around you do it.

So for the rounded box, you might think that you're shifting the box
around along all points inside the sphere, but the same rounded box is
what you get when you move the sphere around all the vectors that fall
inside the cube.

> > So why is the radius added to the cube?
> > At least I work like this. I need a specific cube size with rounded edges.
> > Example:
> >
> > I need a box with 100 x 60 x 20 with roundings 5.

I'd make a module rounded box that does...

> > minkowski()
> > {
> >   cube([100-RoundingBox*2,60-RoundingBox*2,20-RoundingBox*2], center =
> > true);
> >   sphere(r=5, $fn = 36);}

... this.

But because of the "all possible vectors" and then a union across all
those objects, the minkowski operation is very expensive.

So for rounded box I'd write:

module roundedbox (x, y, z, r)
{
  x2=x/2-r;
  y2=y/2-r;
  z2=z/2-r;

  hull () {
    translate ([ x2, y2, z2]) sphere (r=r);
    translate ([ x2, y2,-z2]) sphere (r=r);
    translate ([ x2,-y2, z2]) sphere (r=r);
    translate ([-x2,-y2,-z2]) sphere (r=r);
    translate ([-x2, y2, z2]) sphere (r=r);
    translate ([-x2,-y2,-z2]) sphere (r=r);
    translate ([-x2,-y2, z2]) sphere (r=r);
  }
}

This is much faster than the minkovsky.

        Roger.


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Minkowski rounings with Sphere

lar3ry
In reply to this post by Snörre
If you don't mind using libraries, you could use BOSL2. You can find it at
https://github.com/revarbat/BOSL2
There is a Wiki there as well.

include <BOSL2/std.scad>
$fn=60;

cuboid([100,60,20], rounding=5);

<http://forum.openscad.org/file/t2121/rounded_cube.png>




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org