discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Problems with difference

D
David
Sat, Dec 19, 2020 8:44 PM

Does hull recalculate the edges and smooth out the math?

David

On 12/19/20 9:34 AM, adrianv wrote:

You might find this approach to making polyhedra interesting:

https://www.myminifactory.com/object/3d-print-folding-pentagonal-hexacontahedron-puzzle-85216

I made the tetrahedron and it worked very nicely.  I'm not sure I fully
understand your plan, but if I were trying to assemble 30 of those "diamond"
modules I doubt they would align and close up once I was done.  If you
haven't thought about it you might want to introduce more registration
geometry (e.g. alignment groove down the edge) so that the pieces hopefully
line up properly.  I'd also be worried about the labor of removing support
material and the very small surface area for bed adhesion.

Another observation:  I tried to render the full_skeleton model from the
above example.  It's a pretty obnoxious model because every edge is in there
twice and there are a bunch of repeated spheres at each vertex.  Anyhow, it
crashed opencad RC3 to try to render it.

I made a generic wireframe module that takes out repeated edges and vertices
and was able to render this beast, though it did take 24 minutes.

If you're interested in polyhedra you might also want to take a look at
this:

https://github.com/revarbat/BOSL2/wiki/polyhedra.scad

It will give you vertices and faces for all the catalan solids (and others).

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


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

Does hull recalculate the edges and smooth out the math? David On 12/19/20 9:34 AM, adrianv wrote: > You might find this approach to making polyhedra interesting: > > https://www.myminifactory.com/object/3d-print-folding-pentagonal-hexacontahedron-puzzle-85216 > > I made the tetrahedron and it worked very nicely. I'm not sure I fully > understand your plan, but if I were trying to assemble 30 of those "diamond" > modules I doubt they would align and close up once I was done. If you > haven't thought about it you might want to introduce more registration > geometry (e.g. alignment groove down the edge) so that the pieces hopefully > line up properly. I'd also be worried about the labor of removing support > material and the very small surface area for bed adhesion. > > Another observation: I tried to render the full_skeleton model from the > above example. It's a pretty obnoxious model because every edge is in there > twice and there are a bunch of repeated spheres at each vertex. Anyhow, it > crashed opencad RC3 to try to render it. > > I made a generic wireframe module that takes out repeated edges and vertices > and was able to render this beast, though it did take 24 minutes. > > If you're interested in polyhedra you might also want to take a look at > this: > > https://github.com/revarbat/BOSL2/wiki/polyhedra.scad > > It will give you vertices and faces for all the catalan solids (and others). > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
NH
nop head
Sat, Dec 19, 2020 8:51 PM

Hull doesn't round anything. It just takes all the vertices of the objects
and puts a skin around them. Imagine a rubber balloon stretched over a
bunch of sharp objects.

On Sat, 19 Dec 2020 at 20:45, David ainut@hiwaay.net wrote:

Does hull recalculate the edges and smooth out the math?

David

On 12/19/20 9:34 AM, adrianv wrote:

You might find this approach to making polyhedra interesting:

I made the tetrahedron and it worked very nicely.  I'm not sure I fully
understand your plan, but if I were trying to assemble 30 of those

"diamond"

modules I doubt they would align and close up once I was done.  If you
haven't thought about it you might want to introduce more registration
geometry (e.g. alignment groove down the edge) so that the pieces

hopefully

line up properly.  I'd also be worried about the labor of removing

support

material and the very small surface area for bed adhesion.

Another observation:  I tried to render the full_skeleton model from the
above example.  It's a pretty obnoxious model because every edge is in

there

twice and there are a bunch of repeated spheres at each vertex.  Anyhow,

it

crashed opencad RC3 to try to render it.

I made a generic wireframe module that takes out repeated edges and

vertices

and was able to render this beast, though it did take 24 minutes.

If you're interested in polyhedra you might also want to take a look at
this:

https://github.com/revarbat/BOSL2/wiki/polyhedra.scad

It will give you vertices and faces for all the catalan solids (and

others).

Hull doesn't round anything. It just takes all the vertices of the objects and puts a skin around them. Imagine a rubber balloon stretched over a bunch of sharp objects. On Sat, 19 Dec 2020 at 20:45, David <ainut@hiwaay.net> wrote: > Does hull recalculate the edges and smooth out the math? > > David > > > On 12/19/20 9:34 AM, adrianv wrote: > > You might find this approach to making polyhedra interesting: > > > > > https://www.myminifactory.com/object/3d-print-folding-pentagonal-hexacontahedron-puzzle-85216 > > > > I made the tetrahedron and it worked very nicely. I'm not sure I fully > > understand your plan, but if I were trying to assemble 30 of those > "diamond" > > modules I doubt they would align and close up once I was done. If you > > haven't thought about it you might want to introduce more registration > > geometry (e.g. alignment groove down the edge) so that the pieces > hopefully > > line up properly. I'd also be worried about the labor of removing > support > > material and the very small surface area for bed adhesion. > > > > Another observation: I tried to render the full_skeleton model from the > > above example. It's a pretty obnoxious model because every edge is in > there > > twice and there are a bunch of repeated spheres at each vertex. Anyhow, > it > > crashed opencad RC3 to try to render it. > > > > I made a generic wireframe module that takes out repeated edges and > vertices > > and was able to render this beast, though it did take 24 minutes. > > > > If you're interested in polyhedra you might also want to take a look at > > this: > > > > https://github.com/revarbat/BOSL2/wiki/polyhedra.scad > > > > It will give you vertices and faces for all the catalan solids (and > others). > > > > > > > > > > -- > > Sent from: http://forum.openscad.org/ > > > > _______________________________________________ > > OpenSCAD mailing list > > Discuss@lists.openscad.org > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
adrianv
Sat, Dec 19, 2020 8:57 PM

In the referenced polyhedra code (part of BOSL2) the vertices are computed
and the Linde user-space hull() function (not module) computes all of the
faces of the polyhedron.  I'm not sure if that's what the question was
about.  But it means that the polyhedra library doesn't have to know how to
construct the faces for all of the polyhedra, just the vertices, so that
simplifies things considerably.  The hull function takes a list of points
and computes the face list of the convex hull of the point list, which can
then be passed to polyhedron().

nophead wrote

Hull doesn't round anything. It just takes all the vertices of the objects
and puts a skin around them. Imagine a rubber balloon stretched over a
bunch of sharp objects.

On Sat, 19 Dec 2020 at 20:45, David <

ainut@

> wrote:

Does hull recalculate the edges and smooth out the math?

David

On 12/19/20 9:34 AM, adrianv wrote:

You might find this approach to making polyhedra interesting:

I made the tetrahedron and it worked very nicely.  I'm not sure I fully
understand your plan, but if I were trying to assemble 30 of those

"diamond"

modules I doubt they would align and close up once I was done.  If you
haven't thought about it you might want to introduce more registration
geometry (e.g. alignment groove down the edge) so that the pieces

hopefully

line up properly.  I'd also be worried about the labor of removing

support

material and the very small surface area for bed adhesion.

Another observation:  I tried to render the full_skeleton model from

the

above example.  It's a pretty obnoxious model because every edge is in

there

twice and there are a bunch of repeated spheres at each vertex.

Anyhow,
it

crashed opencad RC3 to try to render it.

I made a generic wireframe module that takes out repeated edges and

vertices

and was able to render this beast, though it did take 24 minutes.

If you're interested in polyhedra you might also want to take a look at
this:

https://github.com/revarbat/BOSL2/wiki/polyhedra.scad

It will give you vertices and faces for all the catalan solids (and

others).

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


OpenSCAD mailing list

Discuss@.openscad

Discuss@.openscad

Discuss@.openscad

In the referenced polyhedra code (part of BOSL2) the vertices are computed and the Linde user-space hull() function (not module) computes all of the faces of the polyhedron. I'm not sure if that's what the question was about. But it means that the polyhedra library doesn't have to know how to construct the faces for all of the polyhedra, just the vertices, so that simplifies things considerably. The hull function takes a list of points and computes the face list of the convex hull of the point list, which can then be passed to polyhedron(). nophead wrote > Hull doesn't round anything. It just takes all the vertices of the objects > and puts a skin around them. Imagine a rubber balloon stretched over a > bunch of sharp objects. > > On Sat, 19 Dec 2020 at 20:45, David &lt; > ainut@ > &gt; wrote: > >> Does hull recalculate the edges and smooth out the math? >> >> David >> >> >> On 12/19/20 9:34 AM, adrianv wrote: >> > You might find this approach to making polyhedra interesting: >> > >> > >> https://www.myminifactory.com/object/3d-print-folding-pentagonal-hexacontahedron-puzzle-85216 >> > >> > I made the tetrahedron and it worked very nicely. I'm not sure I fully >> > understand your plan, but if I were trying to assemble 30 of those >> "diamond" >> > modules I doubt they would align and close up once I was done. If you >> > haven't thought about it you might want to introduce more registration >> > geometry (e.g. alignment groove down the edge) so that the pieces >> hopefully >> > line up properly. I'd also be worried about the labor of removing >> support >> > material and the very small surface area for bed adhesion. >> > >> > Another observation: I tried to render the full_skeleton model from >> the >> > above example. It's a pretty obnoxious model because every edge is in >> there >> > twice and there are a bunch of repeated spheres at each vertex. >> Anyhow, >> it >> > crashed opencad RC3 to try to render it. >> > >> > I made a generic wireframe module that takes out repeated edges and >> vertices >> > and was able to render this beast, though it did take 24 minutes. >> > >> > If you're interested in polyhedra you might also want to take a look at >> > this: >> > >> > https://github.com/revarbat/BOSL2/wiki/polyhedra.scad >> > >> > It will give you vertices and faces for all the catalan solids (and >> others). >> > >> > >> > >> > >> > -- >> > Sent from: http://forum.openscad.org/ >> > >> > _______________________________________________ >> > OpenSCAD mailing list >> > > Discuss@.openscad >> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> > Discuss@.openscad >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Sent from: http://forum.openscad.org/
L
lar3ry
Sat, Dec 19, 2020 9:39 PM

Fun with hull()

$fn=30;

stuff();
translate([50,0,0])
hull() stuff();

module stuff() {
cylinder(5,r=3);
rotate([45,-10,20])
translate([20,0,0])
cylinder(20,r=3);
translate([0,30,5])
cube (10);
translate([36,30,7])
cylinder(10,r1=1,r2=10);
}

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

Fun with hull() $fn=30; stuff(); translate([50,0,0]) hull() stuff(); module stuff() { cylinder(5,r=3); rotate([45,-10,20]) translate([20,0,0]) cylinder(20,r=3); translate([0,30,5]) cube (10); translate([36,30,7]) cylinder(10,r1=1,r2=10); } -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Sat, Dec 19, 2020 11:04 PM

But I can't get the difference operator to shave the half cylinders.

I'm subtracting four tetrahedron where face slices the rod in half.

Your strategy to get a shaved diamond is hard to debug because it resorts
to other vertices besides the diamond ones. I got it using just the 4
extreme diamond vertices:

module flattened_diamond()
intersection() {
scale(2)
// this is the hull of 4 diamond vertices with the origin
polyhedron( [[0,0,0],v[20],v[6],v[18],v[8],v[20]],
[ [0,2,1], [0,3,2], [0,4,3], [0,1,4], [1,2,3,4] ] );
diamond();
}

This shape, despite its name, has not a flat base and will need support for
3d printing. To get a flat base, the diamond needs to be elongated down and
chopped, a non trivial task.

Ideally I wanted them to snap together like lego bricks.

The shape above is unable to snap in another one. I devised some clips that
could keep the diamonds together at each vertex:

module clip6(r) {
rotFromTo(v[6],[0,0,1])
translate(-v[6])
difference() {
translate(v[6])
rotFromTo([0,0,1],v[6])
translate([0,0,-0.44r])
cylinder(r=r, h=0.7
r,center=true);
full_skeleton();
}
}

module clip12(r) {
rotFromTo(v[20],[0,0,1])
translate(-v[20])
difference() {
translate(v[20])
rotFromTo([0,0,1],v[20])
translate([0,0,-0.58r])
cylinder(r=r, h=0.5
r,center=true);
full_skeleton();
}
}

module clips() {
translate([0,0,0.443+0.73/2])
clip6(3);
translate([10,0,0.584.5+0.54.5/2])
clip12(4.5);
}

clips();

[image: Clips.PNG]

But I can't get the difference operator to shave the half cylinders. > I'm subtracting four tetrahedron where face slices the rod in half. > Your strategy to get a shaved diamond is hard to debug because it resorts to other vertices besides the diamond ones. I got it using just the 4 extreme diamond vertices: module flattened_diamond() intersection() { scale(2) // this is the hull of 4 diamond vertices with the origin polyhedron( [[0,0,0],v[20],v[6],v[18],v[8],v[20]], [ [0,2,1], [0,3,2], [0,4,3], [0,1,4], [1,2,3,4] ] ); diamond(); } This shape, despite its name, has not a flat base and will need support for 3d printing. To get a flat base, the diamond needs to be elongated down and chopped, a non trivial task. Ideally I wanted them to snap together like lego bricks. The shape above is unable to snap in another one. I devised some clips that could keep the diamonds together at each vertex: module clip6(r) { rotFromTo(v[6],[0,0,1]) translate(-v[6]) difference() { translate(v[6]) rotFromTo([0,0,1],v[6]) translate([0,0,-0.44*r]) cylinder(r=r, h=0.7*r,center=true); full_skeleton(); } } module clip12(r) { rotFromTo(v[20],[0,0,1]) translate(-v[20]) difference() { translate(v[20]) rotFromTo([0,0,1],v[20]) translate([0,0,-0.58*r]) cylinder(r=r, h=0.5*r,center=true); full_skeleton(); } } module clips() { translate([0,0,0.44*3+0.7*3/2]) clip6(3); translate([10,0,0.58*4.5+0.5*4.5/2]) clip12(4.5); } clips(); [image: Clips.PNG]
R
rugyoga
Sun, Dec 20, 2020 7:06 PM

adrianv:

Cool finds!
But the folding polyhedra doesn't work for our purpose because
the net we would need would be too large for my 3d printer.

That's also why we rejected printing the skeleton.
(Also very wasteful of filament).

Yup, the skeleton has a known bug.
Hence the comment:

// avoid this - it duplicates rods
module skeleton(items) {

Your comment about the registration geometry is spot on.
My next step was to code pips - spheres evenly distributed along the
semi-rods.

The diamond solution was our favourite because:

  • low filament waste
  • easily scaled
  • only needed 30 of them

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

adrianv: Cool finds! But the folding polyhedra doesn't work for our purpose because the net we would need would be too large for my 3d printer. That's also why we rejected printing the skeleton. (Also very wasteful of filament). Yup, the skeleton has a known bug. Hence the comment: // avoid this - it duplicates rods module skeleton(items) { Your comment about the registration geometry is spot on. My next step was to code pips - spheres evenly distributed along the semi-rods. The diamond solution was our favourite because: - low filament waste - easily scaled - only needed 30 of them -- Sent from: http://forum.openscad.org/
A
adrianv
Sun, Dec 20, 2020 7:50 PM

You're clearly down the road on your current approach, and no reason you need
to change if you're happy with it.  But you  might want to take a closer
look at the example I posted.  (Did you think about how big the 3d printer
would have had to be to print the example net in one model?)

The reason I posted that one and not the tetrahedron is that they print a
model much bigger for any normal printer in 13 pieces that snap together.
Presumably you could do the same for the shape you're interested in.  I
don't know the scale of what you're doing, but you could do it with 30
diamonds if they're huge or 12 "pentagons" (with 10 faces) if they're
smaller.

When talking about filament "waste" I'm not sure if you're referring to the
support material and brim needed to print the diamonds, or the total amount
of material needed to complete the project.  The fold up method uses no
support material at all, so in that sense, it's zero waste.  But I suspect
it would use more material than printing all the diamond frames, since it
includes the faces.  Hard to be sure because of all the support material you
need, but it seems likely.

Printing the whole skeleton is going to be very troublesome due to the
internal support material, unless you have a two material printer and can
print soluble support material.

Note that my point about trying to render the full skeleton is not that it's
a good model, but that it shouldn't crash openscad.  You shouldn't be able
to crash openscad by feeding it a nasty model.  Your comment about
duplicating rods doesn't even address the question of spheres at the
vertices, some of which are duplicated 20 times.  And I think the spheres
have more faces than the cylinders, so that's a much worse flaw in the
model.  Cutting the duplication to 10 (by fixing the rod duplication) still
leave a significant issue.

Another note:  you might want to fix the bug in rod() where it passes r1
instead of r.  This causes it to make a cone shaped rod if r1 isn't equal to
1.

rugyoga wrote

adrianv:

Cool finds!
But the folding polyhedra doesn't work for our purpose because
the net we would need would be too large for my 3d printer.

That's also why we rejected printing the skeleton.
(Also very wasteful of filament).

Yup, the skeleton has a known bug.
Hence the comment:

// avoid this - it duplicates rods
module skeleton(items) {

Your comment about the registration geometry is spot on.
My next step was to code pips - spheres evenly distributed along the
semi-rods.

The diamond solution was our favourite because:

  • low filament waste
  • easily scaled
  • only needed 30 of them

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


OpenSCAD mailing list

Discuss@.openscad

You're clearly down the road on your current approach, and no reason you need to change if you're happy with it. But you might want to take a closer look at the example I posted. (Did you think about how big the 3d printer would have had to be to print the example net in one model?) The reason I posted that one and not the tetrahedron is that they print a model much bigger for any normal printer in 13 pieces that snap together. Presumably you could do the same for the shape you're interested in. I don't know the scale of what you're doing, but you could do it with 30 diamonds if they're huge or 12 "pentagons" (with 10 faces) if they're smaller. When talking about filament "waste" I'm not sure if you're referring to the support material and brim needed to print the diamonds, or the total amount of material needed to complete the project. The fold up method uses no support material at all, so in that sense, it's zero waste. But I suspect it would use more material than printing all the diamond frames, since it includes the faces. Hard to be sure because of all the support material you need, but it seems likely. Printing the whole skeleton is going to be very troublesome due to the internal support material, unless you have a two material printer and can print soluble support material. Note that my point about trying to render the full skeleton is not that it's a good model, but that it shouldn't crash openscad. You shouldn't be able to crash openscad by feeding it a nasty model. Your comment about duplicating rods doesn't even address the question of spheres at the vertices, some of which are duplicated 20 times. And I think the spheres have more faces than the cylinders, so that's a much worse flaw in the model. Cutting the duplication to 10 (by fixing the rod duplication) still leave a significant issue. Another note: you might want to fix the bug in rod() where it passes r1 instead of r. This causes it to make a cone shaped rod if r1 isn't equal to 1. rugyoga wrote > adrianv: > > Cool finds! > But the folding polyhedra doesn't work for our purpose because > the net we would need would be too large for my 3d printer. > > That's also why we rejected printing the skeleton. > (Also very wasteful of filament). > > Yup, the skeleton has a known bug. > Hence the comment: > > // avoid this - it duplicates rods > module skeleton(items) { > > Your comment about the registration geometry is spot on. > My next step was to code pips - spheres evenly distributed along the > semi-rods. > > The diamond solution was our favourite because: > - low filament waste > - easily scaled > - only needed 30 of them > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Sent from: http://forum.openscad.org/
DE
David Eccles (gringer)
Sun, Dec 20, 2020 10:12 PM

adrianv wrote

The hull function takes a list of points
and computes the face list of the convex hull of the point list, which can
then be passed to polyhedron()

Huh. So... this should work:

module badCube(){
polyhedron(points=[[-1,-1,-1],[1,1,-1],[-1,1,-1],[1,-1,-1],
[-1,-1, 1],[1,1, 1],[-1,1, 1],[1,-1, 1], [0,0,1.41]],
faces=[[0,1,2,3,4,5,6,7,8]]);
}

color("pink") translate([0,-3,0]) badCube();
color("lightblue") hull(){
badCube();
}

http://forum.openscad.org/file/t452/badCube.png

I was going to request the 'hull' function be slightly modified to take as
optional input a point cloud, but given that it seems to work with a polygon
object with a 'faces' argument that only needs to define the used points [in
any arbitrary order], creating a module that does that is fairly easy, e.g.

module hullPointCloud(points) {
hull()
{
echo([ for(i=[0:(len(points)-1)]) i]);
polyhedron(points=points, faces=[[ for(i=[0:(len(points)-1)]) i]]);
}
}

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

adrianv wrote > The hull function takes a list of points > and computes the face list of the convex hull of the point list, which can > then be passed to polyhedron() Huh. So... this should work: module badCube(){ polyhedron(points=[[-1,-1,-1],[1,1,-1],[-1,1,-1],[1,-1,-1], [-1,-1, 1],[1,1, 1],[-1,1, 1],[1,-1, 1], [0,0,1.41]], faces=[[0,1,2,3,4,5,6,7,8]]); } color("pink") translate([0,-3,0]) badCube(); color("lightblue") hull(){ badCube(); } <http://forum.openscad.org/file/t452/badCube.png> I was going to request the 'hull' function be slightly modified to take as optional input a point cloud, but given that it seems to work with a polygon object with a 'faces' argument that only needs to define the used points [in any arbitrary order], creating a module that does that is fairly easy, e.g. module hullPointCloud(points) { hull() { echo([ for(i=[0:(len(points)-1)]) i]); polyhedron(points=points, faces=[[ for(i=[0:(len(points)-1)]) i]]); } } -- Sent from: http://forum.openscad.org/
A
adrianv
Sun, Dec 20, 2020 10:53 PM

Pay close attention to the difference between functions and modules.  The
hull() module is part of OpenSCAD.  The hull() function was written by Oskar
Linde and is included in the BOSL2 library.  It works on a list of points
and produces a list of faces.

Now as it happens, the thing you list below does work.  This was actually
discussed at length a while back.  Your method is suboptimal because it
creates a large complex face that may get triangulated by polyhedron()
before hull() runs, leading to long run time.  Instead you want to make a
bogus polyhedron with triangular faces:

module hull_points(points)
{
extra = len(points)%3;
faces = [
[for(i=[0:1:extra+2])i],  // Handle extra faces when vertex
count not divisible by 3
for(i=[extra+3:3:len(points)-3])[i,i+1,i+2]
];
hull() polyhedron(points=points, faces=faces);
}

I believe this version can produce warnings in some degenerate cases, which
may be a problem if you run OpenSCAD with "stop on first warning".

In contrast, the hull() function produces a face list as output, not
geometry.  You then invoke polyhedron to draw the polyhedron.  The problem
with the hull() function is that it's not very fast.  Doing 4000 points
takes about a minute.  The hack of hulling a bogus polyhedron is much
faster, since it exploits the built-in hull operator.

David Eccles (gringer) wrote

adrianv wrote

The hull function takes a list of points
and computes the face list of the convex hull of the point list, which
can
then be passed to polyhedron()

Huh. So... this should work:

module badCube(){
polyhedron(points=[[-1,-1,-1],[1,1,-1],[-1,1,-1],[1,-1,-1],
[-1,-1, 1],[1,1, 1],[-1,1, 1],[1,-1, 1], [0,0,1.41]],
faces=[[0,1,2,3,4,5,6,7,8]]);
}

color("pink") translate([0,-3,0]) badCube();
color("lightblue") hull(){
badCube();
}

<http://forum.openscad.org/file/t452/badCube.png>

I was going to request the 'hull' function be slightly modified to take as
optional input a point cloud, but given that it seems to work with a
polygon
object with a 'faces' argument that only needs to define the used points
[in
any arbitrary order], creating a module that does that is fairly easy,
e.g.

module hullPointCloud(points) {
hull()
{
echo([ for(i=[0:(len(points)-1)]) i]);
polyhedron(points=points, faces=[[ for(i=[0:(len(points)-1)]) i]]);
}
}

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


OpenSCAD mailing list

Discuss@.openscad

Pay close attention to the difference between functions and modules. The hull() module is part of OpenSCAD. The hull() function was written by Oskar Linde and is included in the BOSL2 library. It works on a list of points and produces a list of faces. Now as it happens, the thing you list below does work. This was actually discussed at length a while back. Your method is suboptimal because it creates a large complex face that may get triangulated by polyhedron() before hull() runs, leading to long run time. Instead you want to make a bogus polyhedron with triangular faces: module hull_points(points) { extra = len(points)%3; faces = [ [for(i=[0:1:extra+2])i], // Handle extra faces when vertex count not divisible by 3 for(i=[extra+3:3:len(points)-3])[i,i+1,i+2] ]; hull() polyhedron(points=points, faces=faces); } I believe this version can produce warnings in some degenerate cases, which may be a problem if you run OpenSCAD with "stop on first warning". In contrast, the hull() function produces a face list as output, not geometry. You then invoke polyhedron to draw the polyhedron. The problem with the hull() function is that it's not very fast. Doing 4000 points takes about a minute. The hack of hulling a bogus polyhedron is much faster, since it exploits the built-in hull operator. David Eccles (gringer) wrote > adrianv wrote >> The hull function takes a list of points >> and computes the face list of the convex hull of the point list, which >> can >> then be passed to polyhedron() > > Huh. So... this should work: > > module badCube(){ > polyhedron(points=[[-1,-1,-1],[1,1,-1],[-1,1,-1],[1,-1,-1], > [-1,-1, 1],[1,1, 1],[-1,1, 1],[1,-1, 1], [0,0,1.41]], > faces=[[0,1,2,3,4,5,6,7,8]]); > } > > color("pink") translate([0,-3,0]) badCube(); > color("lightblue") hull(){ > badCube(); > } > > &lt;http://forum.openscad.org/file/t452/badCube.png&gt; > > I was going to request the 'hull' function be slightly modified to take as > optional input a point cloud, but given that it seems to work with a > polygon > object with a 'faces' argument that only needs to define the used points > [in > any arbitrary order], creating a module that does that is fairly easy, > e.g. > > module hullPointCloud(points) { > hull() > { > echo([ for(i=[0:(len(points)-1)]) i]); > polyhedron(points=points, faces=[[ for(i=[0:(len(points)-1)]) i]]); > } > } > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Sent from: http://forum.openscad.org/
R
rugyoga
Fri, Jan 1, 2021 11:26 PM

Ronaldo:

Your flattened diamond formulation is much more elegant. Thank you.

My plan to align the diamonds was evenly spaced spherical pips along the
semi rods, like so

module pips(start, finish, n, radius) {
d = (finish - start)/(n2);
for (i = [1:2:2
n-1])
translate(start + i*d) sphere(radius);
}

module flattened_diamond_with_pips(thickness, no_of_pips) {
difference() {
flattened_diamond();
pips(v[6], v[18], no_of_pips, thickness * 0.52);
pips(v[20], v[8], no_of_pips, thickness * 0.52);
}
pips(v[8], v[18], no_of_pips, thickness * 0.5);
pips(v[20], v[6], no_of_pips, thickness * 0.5);
}

To minimize support I stack the diamonds.

module diamond_family(thickness, no_of_pips, n) {
z_offset = [0, 0, 2thickness+1];
for (i = [0:n-1])
translate([0, 0, -v[8][2]]+i
z_offset)
flattened_diamond_with_pips(thickness, no_of_pips);
}

I haven't figured how to generate decent support between the stacked
diamonds.
No gap and they bond with their neighbour.
If I create a gap, the support generated by the slicer (Cura) is almost as
solid.

Thanks for the clips!
i couldn't find the rotFromTo module.
Even if I don't use them in the final model, they're handy to hold the
skeleton while the glue sets.

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

Ronaldo: Your flattened diamond formulation is much more elegant. Thank you. My plan to align the diamonds was evenly spaced spherical pips along the semi rods, like so module pips(start, finish, n, radius) { d = (finish - start)/(n*2); for (i = [1:2:2*n-1]) translate(start + i*d) sphere(radius); } module flattened_diamond_with_pips(thickness, no_of_pips) { difference() { flattened_diamond(); pips(v[6], v[18], no_of_pips, thickness * 0.52); pips(v[20], v[8], no_of_pips, thickness * 0.52); } pips(v[8], v[18], no_of_pips, thickness * 0.5); pips(v[20], v[6], no_of_pips, thickness * 0.5); } To minimize support I stack the diamonds. module diamond_family(thickness, no_of_pips, n) { z_offset = [0, 0, 2*thickness+1]; for (i = [0:n-1]) translate([0, 0, -v[8][2]]+i*z_offset) flattened_diamond_with_pips(thickness, no_of_pips); } I haven't figured how to generate decent support between the stacked diamonds. No gap and they bond with their neighbour. If I create a gap, the support generated by the slicer (Cura) is almost as solid. Thanks for the clips! i couldn't find the rotFromTo module. Even if I don't use them in the final model, they're handy to hold the skeleton while the glue sets. -- Sent from: http://forum.openscad.org/