discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

"empty" openscad model?

MM
Mike Meyer
Tue, Apr 14, 2015 4:35 PM

I've turning my Haskell OpenSCAD model types into instances of Semigroup
and Monoid, but wonder if I've chosen the right "empty" value for monoids.

For those not familiar with it, a monoid is a structure that has an
operation (in this case, union) with an identity object, empty.  The idea
is that a union of anything with empty should return that same thing.

Is there a convenient such object in OpenSCAD? I just used "box 0 0 0",
which seems to do the right thing, but it feels like there ought to be a
better option for "I need to return an object here, but don't really want
to."

I've turning my Haskell OpenSCAD model types into instances of Semigroup and Monoid, but wonder if I've chosen the right "empty" value for monoids. For those not familiar with it, a monoid is a structure that has an operation (in this case, union) with an identity object, empty. The idea is that a union of anything with empty should return that same thing. Is there a convenient such object in OpenSCAD? I just used "box 0 0 0", which seems to do the right thing, but it feels like there ought to be a better option for "I need to return an object here, but don't really want to."
DM
doug moen
Tue, Apr 14, 2015 6:35 PM

I'm not sure if there is a correct answer. I'm not sure if the openscad
geometric operations are mathematically consistent for edge cases like
passing the empty model as an argument.

Mathematically, a 3D shape is a set of points, and the empty shape is the
empty set. So you would expect union(X, empty) = X, intersection(X, empty)
= empty.

In principle, i'd expect cube(0) and group(){} to both behave as the empty
shape, but in practice, they give different results when passed to
intersection. cube(0) behaves as expected, while
intersection(){cube(1);group(){}} returns cube(1).

So I guess that "box 0 0 0" is a reasonable choice.

On 14 April 2015 at 12:35, Mike Meyer mwm@mired.org wrote:

I've turning my Haskell OpenSCAD model types into instances of Semigroup
and Monoid, but wonder if I've chosen the right "empty" value for monoids.

For those not familiar with it, a monoid is a structure that has an
operation (in this case, union) with an identity object, empty.  The idea
is that a union of anything with empty should return that same thing.

Is there a convenient such object in OpenSCAD? I just used "box 0 0 0",
which seems to do the right thing, but it feels like there ought to be a
better option for "I need to return an object here, but don't really want
to."


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

I'm not sure if there is a correct answer. I'm not sure if the openscad geometric operations are mathematically consistent for edge cases like passing the empty model as an argument. Mathematically, a 3D shape is a set of points, and the empty shape is the empty set. So you would expect union(X, empty) = X, intersection(X, empty) = empty. In principle, i'd expect cube(0) and group(){} to both behave as the empty shape, but in practice, they give different results when passed to intersection. cube(0) behaves as expected, while intersection(){cube(1);group(){}} returns cube(1). So I guess that "box 0 0 0" is a reasonable choice. On 14 April 2015 at 12:35, Mike Meyer <mwm@mired.org> wrote: > I've turning my Haskell OpenSCAD model types into instances of Semigroup > and Monoid, but wonder if I've chosen the right "empty" value for monoids. > > For those not familiar with it, a monoid is a structure that has an > operation (in this case, union) with an identity object, empty. The idea > is that a union of anything with empty should return that same thing. > > Is there a convenient such object in OpenSCAD? I just used "box 0 0 0", > which seems to do the right thing, but it feels like there ought to be a > better option for "I need to return an object here, but don't really want > to." > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >