discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

teach me about polygons?

AM
Adrian Mariano
Wed, Sep 8, 2021 3:08 PM

Note that you can avoid the hack of making tiny spheres (and concerns about
time consuming, unnecessary union) by using Oskar Linde's hull() function
which computes the polyhedron vertices and faces of a convex hull.

Original version here:
https://github.com/OskarLinde/scad-utils/blob/master/hull.scad
BOSL2 reference: https://github.com/revarbat/BOSL2/wiki/hull.scad

This is plenty fast for tens of points, but bogs down if you have hundreds
to thousands of points. Another trick that has been discussed in the past
on this list is to create a bogus polyhedron by creating a list of vertices
and just connecting all the vertices together arbitrarily in groups of 3
into triangular faces.  You then pass this bogus polyhedron to the normal
hull module() and it computes the hull() without doing any kind of union.
This is in BOSL2 as hull_points with fast=true.  This runs fast even with
thousands of points.

I agree that making polyhedra is tedious and troublesome and I have used
the hull() method to avoid it for making shapes like dodecahedra.  But a
lot of shapes can be produced by skin() or sweep() operations, where you
specify cross sections of the shape and link those cross sections
together.  The case of a shape with 6 quadrilateral faces is easily handled
this way, e.g. in BOSL2 by skin([bottom,top],slices=0) where bottom and top
are lists of vertices in 3-space.  Doing this with a library routine avoids
the tedium of trying to get your polyhedron right.

I don't understand what Gene is trying to do, but it seems like it should
be possible to do it as a difference of two cube-like objects instead of
piecing together all the sides.

On Wed, Sep 8, 2021 at 6:23 AM dpa sc@pankd.de wrote:

I know this is offtopic but close to the problem "I don't get
polyhedron to work".
I am too lazy for the Polyhedron chaos. If you do too, and have a lot of
points with something simple like a cube I suggest using hull() with small
spheres. It is, compared to the polyhedron, VERY simple. For example I take
the points in Robs link:

p = [
[-5,-5,0]
, [15,-5,0]
, [-5,15,0]
, [15,15,0]
, [0,0,10]
, [0,10,10]
, [10, 0,10]
, [10,10,10]
, [5,5,15]
];

// sphere diameter. To get the correct dimension it should be 0 but you
need something >0
d = 0.0001;

// this takes all points (in any order) and makes a 3D object:
hull() {
for (i=[0 : 1 : len(p)-1]) {
translate(p[i]) sphere(d);
}
}

This is not correct because it is always oversized. But in case of
3D-Print or something similar +0.0001 doesn't matter and you don't need to
build a 3D object first to understand the points and geometry to be able to
construct the virtual 3D object to get the right polyhedron. :)

Am Mi., 8. Sept. 2021 um 07:14 Uhr schrieb Rob Ward rl.ward@bigpond.com:

Polyhedron definitions were very frustrating until I found this web page:

https://gusmith.wordpress.com/2015/09/18/simple-tool-for-creating-polyhedrons-in-openscad/

I have been able to build some quite useful polyhedra since using this
tool/approach. It is slow work, but steady. The logic of building the shape
is better understood by going in small, verifiable steps at a time, and
hence debugging unintended results becomes much easier as well. The overall
designs for me were much quicker to create and errors weren't buried in a
soup of triangles.

Rob
On 7/9/21 10:07 pm, nop head wrote:

You can't take a face of the polyhedron to get an open box. It is not a
manifold solid because the walls would infinitely thin. If it is an
irregular shape that can't be linear_extruded then make two solid
polyhedra, one for the outside and one for the inside and subtract them.

You don't need variables for each point in the polyhedra, they can be any
expression.

On Tue, 7 Sept 2021 at 12:35, Ray West raywest@raywest.com wrote:

On 07/09/2021 08:54, Ronaldo Persiano wrote:

So how do I reorder
to leave out the top and bottom, all I want are the sides which will
then be built up on the inside to do the job, effectively winding up on
the printer as a half box with a big difference removing about half the
box.

I'm still not sure what it looks like to you, but to me, from the above
description, it would be two polygons (not polyhedron) , one inside the
other, extruded, and top and bottom chopped off however you want by
differences.  That will give a solid, and you can add features/whatever,
as you wish.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Note that you can avoid the hack of making tiny spheres (and concerns about time consuming, unnecessary union) by using Oskar Linde's hull() function which computes the polyhedron vertices and faces of a convex hull. Original version here: https://github.com/OskarLinde/scad-utils/blob/master/hull.scad BOSL2 reference: https://github.com/revarbat/BOSL2/wiki/hull.scad This is plenty fast for tens of points, but bogs down if you have hundreds to thousands of points. Another trick that has been discussed in the past on this list is to create a bogus polyhedron by creating a list of vertices and just connecting all the vertices together arbitrarily in groups of 3 into triangular faces. You then pass this bogus polyhedron to the normal hull module() and it computes the hull() without doing any kind of union. This is in BOSL2 as hull_points with fast=true. This runs fast even with thousands of points. I agree that making polyhedra is tedious and troublesome and I have used the hull() method to avoid it for making shapes like dodecahedra. But a lot of shapes can be produced by skin() or sweep() operations, where you specify cross sections of the shape and link those cross sections together. The case of a shape with 6 quadrilateral faces is easily handled this way, e.g. in BOSL2 by skin([bottom,top],slices=0) where bottom and top are lists of vertices in 3-space. Doing this with a library routine avoids the tedium of trying to get your polyhedron right. I don't understand what Gene is trying to do, but it seems like it should be possible to do it as a difference of two cube-like objects instead of piecing together all the sides. On Wed, Sep 8, 2021 at 6:23 AM dpa <sc@pankd.de> wrote: > I know this is offtopic but close to the problem "I don't get > polyhedron to work". > I am too lazy for the Polyhedron chaos. If you do too, and have a lot of > points with something simple like a cube I suggest using hull() with small > spheres. It is, compared to the polyhedron, VERY simple. For example I take > the points in Robs link: > > p = [ > [-5,-5,0] > , [15,-5,0] > , [-5,15,0] > , [15,15,0] > , [0,0,10] > , [0,10,10] > , [10, 0,10] > , [10,10,10] > , [5,5,15] > ]; > > // sphere diameter. To get the correct dimension it should be 0 but you > need something >0 > d = 0.0001; > > // this takes all points (in any order) and makes a 3D object: > hull() { > for (i=[0 : 1 : len(p)-1]) { > translate(p[i]) sphere(d); > } > } > > This is not correct because it is always oversized. But in case of > 3D-Print or something similar +0.0001 doesn't matter and you don't need to > build a 3D object first to understand the points and geometry to be able to > construct the virtual 3D object to get the right polyhedron. :) > > Am Mi., 8. Sept. 2021 um 07:14 Uhr schrieb Rob Ward <rl.ward@bigpond.com>: > >> Polyhedron definitions were very frustrating until I found this web page: >> >> >> https://gusmith.wordpress.com/2015/09/18/simple-tool-for-creating-polyhedrons-in-openscad/ >> >> I have been able to build some quite useful polyhedra since using this >> tool/approach. It is slow work, but steady. The logic of building the shape >> is better understood by going in small, verifiable steps at a time, and >> hence debugging unintended results becomes much easier as well. The overall >> designs for me were much quicker to create and errors weren't buried in a >> soup of triangles. >> >> Rob >> On 7/9/21 10:07 pm, nop head wrote: >> >> You can't take a face of the polyhedron to get an open box. It is not a >> manifold solid because the walls would infinitely thin. If it is an >> irregular shape that can't be linear_extruded then make two solid >> polyhedra, one for the outside and one for the inside and subtract them. >> >> You don't need variables for each point in the polyhedra, they can be any >> expression. >> >> On Tue, 7 Sept 2021 at 12:35, Ray West <raywest@raywest.com> wrote: >> >>> >>> On 07/09/2021 08:54, Ronaldo Persiano wrote: >>> > So how do I reorder >>> > to leave out the top and bottom, all I want are the sides which will >>> > then be built up on the inside to do the job, effectively winding up on >>> > the printer as a half box with a big difference removing about half the >>> > box. >>> >>> >>> I'm still not sure what it looks like to you, but to me, from the above >>> description, it would be two polygons (not polyhedron) , one inside the >>> other, extruded, and top and bottom chopped off however you want by >>> differences. That will give a solid, and you can add features/whatever, >>> as you wish. >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
BR
Bob Roos
Thu, Sep 9, 2021 11:17 AM

Hi Father Horton,

Thank you for this. 

Monday, September 6, 2021, 8:46:16 PM, you wrote:

You have to go consistently either clockwise or counterclockwise (from the outside looking in). You can't go back and forth. That's why the points in CubeFaces are ordered the way they are. 

Rob Ward
Thank you for this.
 
Polyhedron definitions were very frustrating until I found this web page:
https://gusmith.wordpress.com/2015/09/18/simple-tool-for-creating-polyhedrons-in-openscad/
 

-- 
have Fun,
 Bob                           mailto:roosbob@wybatap.com

Hi Father Horton, Thank you for this.  Monday, September 6, 2021, 8:46:16 PM, you wrote: > You have to go consistently either clockwise or counterclockwise (from the outside looking in). You can't go back and forth. That's why the points in CubeFaces are ordered the way they are.  Rob Ward Thank you for this.   Polyhedron definitions were very frustrating until I found this web page: https://gusmith.wordpress.com/2015/09/18/simple-tool-for-creating-polyhedrons-in-openscad/   --  have Fun,  Bob                           mailto:roosbob@wybatap.com