discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Polygon in 3D space?

H
herdima
Thu, Oct 12, 2017 12:58 PM

Hi Thomas,

degenerate faces and degenerate polyhedra are quite useful for what you want
to do.
A flat, degenerate polyhedron can be generated from even more degenerate
triangles like this:

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

polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8]]);
// Or for a non-degenerate result:
//polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8], [0,0,10]]);

From the above it is trivial to linear extrude by some vector v.

One way for this is to hull with the translated result:

hull()
for(i=[0,1])
translate(i*[-2,-6,0])
polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8]]);

Degenerate faces and degenerate polyhedra are not documented in OpenSCAD.
So I am not sure if the above will remain possible in all future versions.
Maybe someone can tell. I am using 2015.03-2.

Martin
www.panohero.de

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

Hi Thomas, degenerate faces and degenerate polyhedra are quite useful for what you want to do. A flat, degenerate polyhedron can be generated from even more degenerate triangles like this: module polyhedrify_points(points) { faces = [for(i=[0:len(points)-1]) [i,i,i]]; hull() polyhedron(points, faces); } polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8]]); // Or for a non-degenerate result: //polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8], [0,0,10]]); >From the above it is trivial to linear extrude by some vector v. One way for this is to hull with the translated result: hull() for(i=[0,1]) translate(i*[-2,-6,0]) polyhedrify_points([[2,2,2], [2,8,8], [7,2,2], [7,8,8]]); Degenerate faces and degenerate polyhedra are not documented in OpenSCAD. So I am not sure if the above will remain possible in all future versions. Maybe someone can tell. I am using 2015.03-2. Martin www.panohero.de -- Sent from: http://forum.openscad.org/