Trigger warning: Rant ahead!
So this rounded business talk goes round and round.
First its rounded polygons.
Then rounded 3d primitives.
Then it turns into rounded 3d boolean operations.
Some suggest the operations need to be built ins.
Some counter it can all be done in user-space with polyhedrons.
Followed by a long exchange that in essence asks how to replicate well
established B-rep operations like those in Parasolid/Opencascade etc based
systems, but now in open-scad, in user-space. Great fun project and all but
completely insane as a task.
Some suggest various nested Minkowski operations as a side note, always with
some huge buts.
Rinse and repeat every few months.
The argument that time consuming builtin operations breaks fast preview
completely falls apart when the suggested alternative is hundred times
slower user-space polyhedron operations. Implemented with only lists of
list, no mutable data or linked structures and some good old float point
errors as a throwback to the very core issue why precision math CGAL was
chosen for Openscad in the first place.
Addressing every other feature request with "solve it yourself in
user-space" cannot be a sane way forward when those ideas already been
ruminated exhaustively in ever repeating waves.
Maybe a more honest answer is that it is hard, very hard, close to
impossible, to implement rounded modelling in this kind of preview/render
hybrid system. A system that unfortunately painted itself into a bit of a
corner from the beginning. But then again it is infinitely harder to do all
that in the so called user-space.
If a willing few has them magic skills to solve this in pure openscad then
surely they are the kind that could expand CGAL with similar functions for
far lesser effort.
end rant.
My question to the community is: What level of features is sane to be solved
by users and what
belongs in the developer world?
--
Sent from: http://forum.openscad.org/
I am the OP of the recent reddit post on this subject:
https://www.reddit.com/r/openscad/comments/bfx897/openscad_rounded_boxes/
Being just a beginner I had no idea how to use the hull() function. A day
later I now I know how to use hull() I can say it definitely solves the
problem of generated rounded solid a non issue. The hull() function also is
very fast and is almost instant when used in render(). So in short, rounded
shapes is easy if you just use the hull() function.
A rounded cube with hull():
module roundCube(w, d, h, radius)
{
hull()
{
translate([w / 2, d / 2, 0]) sphere(radius);
translate([w / 2, d / -2, 0]) sphere(radius);
translate([-w / 2, d / 2, 0]) sphere(radius);
translate([-w / 2, d / -2, 0]) sphere(radius);
translate([w / 2, d / 2, h]) sphere(radius);
translate([w / 2, d / -2, h]) sphere(radius);
translate([-w / 2, d / 2, h]) sphere(radius);
translate([-w / 2, d / -2, h]) sphere(radius);
}
}
Easy peezee and done.
Hull only works for convex shapes, though. Minkowsky works for non-convex,
but is much slower
On Thu, 25 Apr 2019, 16:16 Anthony Walter, sysrpl@gmail.com wrote:
I am the OP of the recent reddit post on this subject:
https://www.reddit.com/r/openscad/comments/bfx897/openscad_rounded_boxes/
Being just a beginner I had no idea how to use the hull() function. A day
later I now I know how to use hull() I can say it definitely solves the
problem of generated rounded solid a non issue. The hull() function also is
very fast and is almost instant when used in render(). So in short, rounded
shapes is easy if you just use the hull() function.
A rounded cube with hull():
module roundCube(w, d, h, radius)
{
hull()
{
translate([w / 2, d / 2, 0]) sphere(radius);
translate([w / 2, d / -2, 0]) sphere(radius);
translate([-w / 2, d / 2, 0]) sphere(radius);
translate([-w / 2, d / -2, 0]) sphere(radius);
translate([w / 2, d / 2, h]) sphere(radius);
translate([w / 2, d / -2, h]) sphere(radius);
translate([-w / 2, d / 2, h]) sphere(radius);
translate([-w / 2, d / -2, h]) sphere(radius);
}
}
Easy peezee and done.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 25.04.19 21:44, TLC123 wrote:
My question to the community is: What level of features is sane
to be solved by users and what belongs in the developer world?
This is a very good question. Burying it in this topic after the
rant seems a bit strange though...
Also, I suspect there's no easy and single answer. Maybe that
discussion could be had, but separately. So I won't start now.
ciao,
Torsten.
I don't claim to really understand the math, but a Minkowski sum
basically involves moving an object A along the entire perimeter of
another object B, and the result is the entire area swept. Right?
Is there another operation (Minkowski difference, maybe?) that moves B
around the inside of A, and that doesn't include anything that B can't
reach? (Do I need to draw a picture to describe what I mean?)
This latter operation would seem like a powerful way to take a shape and
round all of its edges, while preserving its major dimensions.
On 4/25/2019 4:25 PM, Jordan Brown wrote:
I don't claim to really understand the math, but a Minkowski sum
basically involves moving an object A along the entire perimeter of
another object B, and the result is the entire area swept. Right?
Is there another operation (Minkowski difference, maybe?) that moves B
around the inside of A, and that doesn't include anything that B
can't reach? (Do I need to draw a picture to describe what I mean?)
This latter operation would seem like a powerful way to take a shape
and round all of its edges, while preserving its major dimensions.
And is often the case, a few searches and clicks later:
https://en.wikipedia.org/wiki/Opening_(morphology)
See https://github.com/openscad/openscad/issues/1678
Minkwoski difference can be done with Minkowski sum and difference but it
is very slow and uses an enormous amount of memory for values of $fn that
make things smooth.
On Fri, 26 Apr 2019 at 06:25, Jordan Brown openscad@jordan.maileater.net
wrote:
On 4/25/2019 4:25 PM, Jordan Brown wrote:
I don't claim to really understand the math, but a Minkowski sum basically
involves moving an object A along the entire perimeter of another object B,
and the result is the entire area swept. Right?
Is there another operation (Minkowski difference, maybe?) that moves B
around the inside of A, and that doesn't include anything that B can't
reach? (Do I need to draw a picture to describe what I mean?)
This latter operation would seem like a powerful way to take a shape and
round all of its edges, while preserving its major dimensions.
And is often the case, a few searches and clicks later:
https://en.wikipedia.org/wiki/Opening_(morphology)
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Even for convex shapes hull has limitations. Anthony, if you think rounding
is "easy peezee" then first I suggest fixing the module so the rounded cube
is the right size rather than 2*r oversized. Then I ask how you would make
a rounded pyramid with an arbitrary base polygon and apex that is a
designated size and not oversized. Next, how would you use the hull method
to make a cylinder with rounded ends? What if the cylinder's ends are not
normal to its axis? If that's too easy then suppose I construct a parabola
and extrude it. How would you round that?
data = [for(x=[-2:.05:2])[x,x*x]];
linear_extrude(height=4)polygon(data);
I'm not saying these things can't be done. For making a rounded polyhedron
you need to put the spheres in the right place, which is not "easy peezee"
in my opinion when the polyhedron is not a cube. (Oh, and don't forget that
spheres are actually polyhedra, and undersized.) And the methods that leap
to mind for the cylinder seem little complex. For the case of the parabolic
shape I don't see a way of using hull that is easier than just generating
the whole shape directly.
The other problem with using hull is that it assumes that it makes sense to
build up your convex object from a union of convex objects. What if you
create your convex object through difference() operations? Then you cannot
round the final object using hull() operations. If everything has to be
constructed with hull() it limits your options for how you can model stuff.
As acwest notes, non-convex shapes cannot be rounded with hull. In my
experience, nothing I design ends up being convex. I've been pondering the
task of making a box where the inside joint between the walls and base is
rounded and the top edge is rounded. To do this for a general box (with an
arbitrary shaped base) appears to be very difficult.
Regarding run time, hull() can be slow. In fact, for polyhedra with large
numbers of faces it seems that minkowski() is faster than hull(). I just
did a timing test and the hull of 50 spheres with $fn=32 took 38 seconds to
preview. I understand that technically what's slow for hull() is not the
hull operation but the unavoidable yet unnecessary union operation between
all the spheres.
It is possible to make a general minkowski rounding function with 3 calls to
minkowski. But is has the limitation that the shape cannot have any areas
thinner than the roundover radius. Also there is the question of speed.
Reportedly rounding the union of a cylinder and cube (that don't meet at
right angles) takes 12 hours. And of course it enforces the same rounding
radius globally on the model, which may not be what you need.
acwest wrote
Hull only works for convex shapes, though. Minkowsky works for non-convex,
but is much slower
On Thu, 25 Apr 2019, 16:16 Anthony Walter, <
sysrpl@
> wrote:
I am the OP of the recent reddit post on this subject:
https://www.reddit.com/r/openscad/comments/bfx897/openscad_rounded_boxes/
Being just a beginner I had no idea how to use the hull() function. A day
later I now I know how to use hull() I can say it definitely solves the
problem of generated rounded solid a non issue. The hull() function also
is
very fast and is almost instant when used in render(). So in short,
rounded
shapes is easy if you just use the hull() function.
A rounded cube with hull():
module roundCube(w, d, h, radius)
{
hull()
{
translate([w / 2, d / 2, 0]) sphere(radius);
translate([w / 2, d / -2, 0]) sphere(radius);
translate([-w / 2, d / 2, 0]) sphere(radius);
translate([-w / 2, d / -2, 0]) sphere(radius);
translate([w / 2, d / 2, h]) sphere(radius);
translate([w / 2, d / -2, h]) sphere(radius);
translate([-w / 2, d / 2, h]) sphere(radius);
translate([-w / 2, d / -2, h]) sphere(radius);
}
}
Easy peezee and done.
--
Sent from: http://forum.openscad.org/
Hull is only slow if it has an implicit union inside it. For example if you
place spheres with a for loop or a common translation or rotation then they
get unioned first and that is very slow with CGAL. If you place each sphere
individually, like the example above, then hull is very fast,
Spheres can be made exact by rotate extruding a semi circle with $fn a
multiple of 4. I redefine sphere myself to be that.
//
// Replicate OpenSCAD logic to calculate number of sides from radius
//
function r2sides(r) = $fn ? $fn : ceil(max(min(360/ $fa, r * 2 * PI / $fs),
5));
//
// Round up number of sides to multiple of 4 to ensure points on all axes
//
function r2sides4n(r) = floor((r2sides(r) + 3) / 4) * 4;
//
// Circle with multiple of 4 vertices
//
module Circle(r, d = undef) {
R = is_undef(d) ? r : d / 2;
circle(R, $fn = r2sides4n(R));
}
//
// Semi circle
//
module semi_circle(r)
intersection() {
Circle(r);
sq = r + 1;
translate([-sq, 0])
square([2 * sq, sq]);
}
//
// Sphere that has vertices on all three axes. Has the advantage of giving
correct dimensions when hulled
//
module sphere(r = 1, d = undef) {
R = is_undef(d) ? r : d / 2;
rotate_extrude($fn = r2sides4n(R))
rotate(-90)
semi_circle(R);
}
[image: spheres.png]
I manage to make everything I need with these techniques but a version of
3D Minkowski that would run before the heat death of the universe and
consume less than an infinite amount of memory would be nice.
On Fri, 26 Apr 2019 at 12:16, adrianv avm4@cornell.edu wrote:
Even for convex shapes hull has limitations. Anthony, if you think
rounding
is "easy peezee" then first I suggest fixing the module so the rounded cube
is the right size rather than 2*r oversized. Then I ask how you would make
a rounded pyramid with an arbitrary base polygon and apex that is a
designated size and not oversized. Next, how would you use the hull method
to make a cylinder with rounded ends? What if the cylinder's ends are not
normal to its axis? If that's too easy then suppose I construct a parabola
and extrude it. How would you round that?
data = [for(x=[-2:.05:2])[x,x*x]];
linear_extrude(height=4)polygon(data);
I'm not saying these things can't be done. For making a rounded polyhedron
you need to put the spheres in the right place, which is not "easy peezee"
in my opinion when the polyhedron is not a cube. (Oh, and don't forget
that
spheres are actually polyhedra, and undersized.) And the methods that leap
to mind for the cylinder seem little complex. For the case of the
parabolic
shape I don't see a way of using hull that is easier than just generating
the whole shape directly.
The other problem with using hull is that it assumes that it makes sense to
build up your convex object from a union of convex objects. What if you
create your convex object through difference() operations? Then you cannot
round the final object using hull() operations. If everything has to be
constructed with hull() it limits your options for how you can model
stuff.
As acwest notes, non-convex shapes cannot be rounded with hull. In my
experience, nothing I design ends up being convex. I've been pondering the
task of making a box where the inside joint between the walls and base is
rounded and the top edge is rounded. To do this for a general box (with an
arbitrary shaped base) appears to be very difficult.
Regarding run time, hull() can be slow. In fact, for polyhedra with large
numbers of faces it seems that minkowski() is faster than hull(). I just
did a timing test and the hull of 50 spheres with $fn=32 took 38 seconds to
preview. I understand that technically what's slow for hull() is not the
hull operation but the unavoidable yet unnecessary union operation between
all the spheres.
It is possible to make a general minkowski rounding function with 3 calls
to
minkowski. But is has the limitation that the shape cannot have any areas
thinner than the roundover radius. Also there is the question of speed.
Reportedly rounding the union of a cylinder and cube (that don't meet at
right angles) takes 12 hours. And of course it enforces the same rounding
radius globally on the model, which may not be what you need.
acwest wrote
Hull only works for convex shapes, though. Minkowsky works for
non-convex,
but is much slower
On Thu, 25 Apr 2019, 16:16 Anthony Walter, <
sysrpl@
> wrote:
I am the OP of the recent reddit post on this subject:
Being just a beginner I had no idea how to use the hull() function. A
day
later I now I know how to use hull() I can say it definitely solves the
problem of generated rounded solid a non issue. The hull() function also
is
very fast and is almost instant when used in render(). So in short,
rounded
shapes is easy if you just use the hull() function.
A rounded cube with hull():
module roundCube(w, d, h, radius)
{
hull()
{
translate([w / 2, d / 2, 0]) sphere(radius);
translate([w / 2, d / -2, 0]) sphere(radius);
translate([-w / 2, d / 2, 0]) sphere(radius);
translate([-w / 2, d / -2, 0]) sphere(radius);
translate([w / 2, d / 2, h]) sphere(radius);
translate([w / 2, d / -2, h]) sphere(radius);
translate([-w / 2, d / 2, h]) sphere(radius);
translate([-w / 2, d / -2, h]) sphere(radius);
}
}
Easy peezee and done.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
nophead wrote
Hull is only slow if it has an implicit union inside it. For example if
you
place spheres with a for loop or a common translation or rotation then
they
get unioned first and that is very slow with CGAL. If you place each
sphere
individually, like the example above, then hull is very fast,
I had forgotten about that. It's not a very attractive coding method if you
have a lot of stuff to hull, though. Also note that I had an error in my
code. It actually takes 3.5 minutes to compute the hull of the 50 spheres.
Spheres can be made exact by rotate extruding a semi circle with $fn a
multiple of 4. I redefine sphere myself to be that.
That's a nice idea.
Note, however, that it only makes hulls exact for faces parallel to the
coordinate planes. In my example problem of the pyramid it's going to be
very difficult to figure out the effective radius of the "sphere" in the
direction of each face so that you can position them exactly right to get a
hull that actually has the exact dimensions desired.
--
Sent from: http://forum.openscad.org/