discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Connect planes with corresponding vertices

B
Bananapeel
Fri, Jan 30, 2015 7:01 PM

Hi everyone

I have a really complex (for me) problem that I can't seem to solve. It is a
subproblem of an attempt to extrude a 2d shape along a bezier curve.

I have a list of (programmatically generated) polygons stored as vectors,
shown below.

poly1 = [
[0,0,0],
[0, 40,  0],
[30, 20, 0],
[50, 30, 0],
[50, 0, 0]
];

poly2 = [
[0,0,10],
[0, 50,  10],
[30, 30, 10],
[50, 20, 10],
[50, 0, 10]
];

shape = [poly1, poly2, ..., polyN];

What I want is to make these into a solid shape. poly1 forms the bottom,
polyN forms the top, the edges of the rest work to define the walls of the
polygons.

The number of vertices in all polygons is the same, in this example 5 (in
the real world a lot higher).
And the vertices are corresponding (ie the first vertex of first polygon is
to be connected with the first of the second, see below.) The z coordinate
is always the same for all vertices in each polygon. So a list of flat
faces.

Perhaps a picture makes it more clear. I have drawn in a few triangles in
red and blue. Essentially the whole shape should be covered by them to make
a solid.

http://forum.openscad.org/file/n11326/layers.png

Code:

planes = [[[-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [126.808,
257.216, 0], [132.264, 275.928, 0], [141.416, 291.232, 0], [154.312,
303.224, 0], [171, 312, 0], [171, 312, 0], [-1, 312, 0]], [[-1, 0, 31.2],
[145.624, 0, 31.2], [145.624, 235, 31.2], [145.624, 235, 31.2], [147.432,
257.216, 31.2], [152.888, 275.928, 31.2], [162.04, 291.232, 31.2], [174.936,
303.224, 31.2], [191.624, 312, 31.2], [191.624, 312, 31.2], [-1, 312,
31.2]], [[-1, 0, 62.4], [165.655, 0, 62.4], [165.655, 235, 62.4], [165.655,
235, 62.4], [167.463, 257.216, 62.4], [172.919, 275.928, 62.4], [182.071,
291.232, 62.4], [194.967, 303.224, 62.4], [211.655, 312, 62.4], [211.655,
312, 62.4], [-1, 312, 62.4]], [[-1, 0, 93.6], [184.703, 0, 93.6], [184.703,
235, 93.6], [184.703, 235, 93.6], [186.511, 257.216, 93.6], [191.967,
275.928, 93.6], [201.119, 291.232, 93.6], [214.015, 303.224, 93.6],
[230.703, 312, 93.6], [230.703, 312, 93.6], [-1, 312, 93.6]], [[-1, 0,
124.8], [202.305, 0, 124.8], [202.305, 235, 124.8], [202.305, 235, 124.8],
[204.113, 257.216, 124.8], [209.569, 275.928, 124.8], [218.721, 291.232,
124.8], [231.617, 303.224, 124.8], [248.305, 312, 124.8], [248.305, 312,
124.8], [-1, 312, 124.8]], [[-1, 0, 156], [217.843, 0, 156], [217.843, 235,
156], [217.843, 235, 156], [219.651, 257.216, 156], [225.107, 275.928, 156],
[234.259, 291.232, 156], [247.155, 303.224, 156], [263.843, 312, 156],
[263.843, 312, 156], [-1, 312, 156]], [[-1, 0, 187.2], [230.446, 0, 187.2],
[230.446, 235, 187.2], [230.446, 235, 187.2], [232.254, 257.216, 187.2],
[237.71, 275.928, 187.2], [246.862, 291.232, 187.2], [259.758, 303.224,
187.2], [276.446, 312, 187.2], [276.446, 312, 187.2], [-1, 312, 187.2]],
[[-1, 0, 218.4], [238.665, 0, 218.4], [238.665, 235, 218.4], [238.665, 235,
218.4], [240.473, 257.216, 218.4], [245.929, 275.928, 218.4], [255.081,
291.232, 218.4], [267.977, 303.224, 218.4], [284.665, 312, 218.4], [284.665,
312, 218.4], [-1, 312, 218.4]], [[-1, 0, 249.6], [239.742, 0, 249.6],
[239.742, 235, 249.6], [239.742, 235, 249.6], [241.55, 257.216, 249.6],
[247.006, 275.928, 249.6], [256.158, 291.232, 249.6], [269.054, 303.224,
249.6], [285.742, 312, 249.6], [285.742, 312, 249.6], [-1, 312, 249.6]],
[[-1, 0, 280.8], [226.617, 0, 280.8], [226.617, 235, 280.8], [226.617, 235,
280.8], [228.425, 257.216, 280.8], [233.881, 275.928, 280.8], [243.033,
291.232, 280.8], [255.929, 303.224, 280.8], [272.617, 312, 280.8], [272.617,
312, 280.8], [-1, 312, 280.8]], [[-1, 0, 312], [130.91, 0, 312], [130.91,
235, 312], [130.91, 235, 312], [132.718, 257.216, 312], [138.174, 275.928,
312], [147.326, 291.232, 312], [160.222, 303.224, 312], [176.91, 312, 312],
[176.91, 312, 312], [-1, 312, 312]]];

//      plane_extrude()
//      extrudes a face to make it visible for debugging
module plane_extrude(face, height=1) {
translate([0, 0, face[0][2]])
linear_extrude(height=height)
polygon([for (i=face) [ i[0], i[1] ] ]);
}

// debug
for (i=planes) {
plane_extrude(i);
}

On side note, it would be nice if echo() formatted vectors differently when
they are nested. For example by printing each sub-vector on a new line.

Have a nice day,
Bananapeel :)

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi everyone I have a really complex (for me) problem that I can't seem to solve. It is a subproblem of an attempt to extrude a 2d shape along a bezier curve. I have a list of (programmatically generated) polygons stored as vectors, shown below. poly1 = [ [0,0,0], [0, 40, 0], [30, 20, 0], [50, 30, 0], [50, 0, 0] ]; poly2 = [ [0,0,10], [0, 50, 10], [30, 30, 10], [50, 20, 10], [50, 0, 10] ]; shape = [poly1, poly2, ..., polyN]; What I want is to make these into a solid shape. poly1 forms the bottom, polyN forms the top, the edges of the rest work to define the walls of the polygons. The number of vertices in all polygons is the same, in this example 5 (in the real world a lot higher). And the vertices are corresponding (ie the first vertex of first polygon is to be connected with the first of the second, see below.) The z coordinate is always the same for all vertices in each polygon. So a list of flat faces. Perhaps a picture makes it more clear. I have drawn in a few triangles in red and blue. Essentially the whole shape should be covered by them to make a solid. <http://forum.openscad.org/file/n11326/layers.png> Code: planes = [[[-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [126.808, 257.216, 0], [132.264, 275.928, 0], [141.416, 291.232, 0], [154.312, 303.224, 0], [171, 312, 0], [171, 312, 0], [-1, 312, 0]], [[-1, 0, 31.2], [145.624, 0, 31.2], [145.624, 235, 31.2], [145.624, 235, 31.2], [147.432, 257.216, 31.2], [152.888, 275.928, 31.2], [162.04, 291.232, 31.2], [174.936, 303.224, 31.2], [191.624, 312, 31.2], [191.624, 312, 31.2], [-1, 312, 31.2]], [[-1, 0, 62.4], [165.655, 0, 62.4], [165.655, 235, 62.4], [165.655, 235, 62.4], [167.463, 257.216, 62.4], [172.919, 275.928, 62.4], [182.071, 291.232, 62.4], [194.967, 303.224, 62.4], [211.655, 312, 62.4], [211.655, 312, 62.4], [-1, 312, 62.4]], [[-1, 0, 93.6], [184.703, 0, 93.6], [184.703, 235, 93.6], [184.703, 235, 93.6], [186.511, 257.216, 93.6], [191.967, 275.928, 93.6], [201.119, 291.232, 93.6], [214.015, 303.224, 93.6], [230.703, 312, 93.6], [230.703, 312, 93.6], [-1, 312, 93.6]], [[-1, 0, 124.8], [202.305, 0, 124.8], [202.305, 235, 124.8], [202.305, 235, 124.8], [204.113, 257.216, 124.8], [209.569, 275.928, 124.8], [218.721, 291.232, 124.8], [231.617, 303.224, 124.8], [248.305, 312, 124.8], [248.305, 312, 124.8], [-1, 312, 124.8]], [[-1, 0, 156], [217.843, 0, 156], [217.843, 235, 156], [217.843, 235, 156], [219.651, 257.216, 156], [225.107, 275.928, 156], [234.259, 291.232, 156], [247.155, 303.224, 156], [263.843, 312, 156], [263.843, 312, 156], [-1, 312, 156]], [[-1, 0, 187.2], [230.446, 0, 187.2], [230.446, 235, 187.2], [230.446, 235, 187.2], [232.254, 257.216, 187.2], [237.71, 275.928, 187.2], [246.862, 291.232, 187.2], [259.758, 303.224, 187.2], [276.446, 312, 187.2], [276.446, 312, 187.2], [-1, 312, 187.2]], [[-1, 0, 218.4], [238.665, 0, 218.4], [238.665, 235, 218.4], [238.665, 235, 218.4], [240.473, 257.216, 218.4], [245.929, 275.928, 218.4], [255.081, 291.232, 218.4], [267.977, 303.224, 218.4], [284.665, 312, 218.4], [284.665, 312, 218.4], [-1, 312, 218.4]], [[-1, 0, 249.6], [239.742, 0, 249.6], [239.742, 235, 249.6], [239.742, 235, 249.6], [241.55, 257.216, 249.6], [247.006, 275.928, 249.6], [256.158, 291.232, 249.6], [269.054, 303.224, 249.6], [285.742, 312, 249.6], [285.742, 312, 249.6], [-1, 312, 249.6]], [[-1, 0, 280.8], [226.617, 0, 280.8], [226.617, 235, 280.8], [226.617, 235, 280.8], [228.425, 257.216, 280.8], [233.881, 275.928, 280.8], [243.033, 291.232, 280.8], [255.929, 303.224, 280.8], [272.617, 312, 280.8], [272.617, 312, 280.8], [-1, 312, 280.8]], [[-1, 0, 312], [130.91, 0, 312], [130.91, 235, 312], [130.91, 235, 312], [132.718, 257.216, 312], [138.174, 275.928, 312], [147.326, 291.232, 312], [160.222, 303.224, 312], [176.91, 312, 312], [176.91, 312, 312], [-1, 312, 312]]]; // plane_extrude() // extrudes a face to make it visible for debugging module plane_extrude(face, height=1) { translate([0, 0, face[0][2]]) linear_extrude(height=height) polygon([for (i=face) [ i[0], i[1] ] ]); } // debug for (i=planes) { plane_extrude(i); } On side note, it would be nice if echo() formatted vectors differently when they are nested. For example by printing each sub-vector on a new line. Have a nice day, Bananapeel :) -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AP
Andrew Plumb
Fri, Jan 30, 2015 8:29 PM

In pseudo-code:

delta=0.1;
hull() {
for(pt=poly1){
translate(pt) sphere(r=delta);
}
for(pt=poly2){
translate(pt) sphere(r=delta);
}
}

...or some variation on that, use hull() to fill the gap. You may have to subdivide your polys into sets of to/from triangle pairs to handle concave regions.

Andrew

Sent from my iPhone

On Jan 30, 2015, at 2:01 PM, Bananapeel lunatica.xiaoyu@gmail.com wrote:

Hi everyone

I have a really complex (for me) problem that I can't seem to solve. It is a
subproblem of an attempt to extrude a 2d shape along a bezier curve.

I have a list of (programmatically generated) polygons stored as vectors,
shown below.

poly1 = [
[0,0,0],
[0, 40,  0],
[30, 20, 0],
[50, 30, 0],
[50, 0, 0]
];

poly2 = [
[0,0,10],
[0, 50,  10],
[30, 30, 10],
[50, 20, 10],
[50, 0, 10]
];

shape = [poly1, poly2, ..., polyN];

What I want is to make these into a solid shape. poly1 forms the bottom,
polyN forms the top, the edges of the rest work to define the walls of the
polygons.

The number of vertices in all polygons is the same, in this example 5 (in
the real world a lot higher).
And the vertices are corresponding (ie the first vertex of first polygon is
to be connected with the first of the second, see below.) The z coordinate
is always the same for all vertices in each polygon. So a list of flat
faces.

Perhaps a picture makes it more clear. I have drawn in a few triangles in
red and blue. Essentially the whole shape should be covered by them to make
a solid.

http://forum.openscad.org/file/n11326/layers.png

Code:

planes = [[[-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [126.808,
257.216, 0], [132.264, 275.928, 0], [141.416, 291.232, 0], [154.312,
303.224, 0], [171, 312, 0], [171, 312, 0], [-1, 312, 0]], [[-1, 0, 31.2],
[145.624, 0, 31.2], [145.624, 235, 31.2], [145.624, 235, 31.2], [147.432,
257.216, 31.2], [152.888, 275.928, 31.2], [162.04, 291.232, 31.2], [174.936,
303.224, 31.2], [191.624, 312, 31.2], [191.624, 312, 31.2], [-1, 312,
31.2]], [[-1, 0, 62.4], [165.655, 0, 62.4], [165.655, 235, 62.4], [165.655,
235, 62.4], [167.463, 257.216, 62.4], [172.919, 275.928, 62.4], [182.071,
291.232, 62.4], [194.967, 303.224, 62.4], [211.655, 312, 62.4], [211.655,
312, 62.4], [-1, 312, 62.4]], [[-1, 0, 93.6], [184.703, 0, 93.6], [184.703,
235, 93.6], [184.703, 235, 93.6], [186.511, 257.216, 93.6], [191.967,
275.928, 93.6], [201.119, 291.232, 93.6], [214.015, 303.224, 93.6],
[230.703, 312, 93.6], [230.703, 312, 93.6], [-1, 312, 93.6]], [[-1, 0,
124.8], [202.305, 0, 124.8], [202.305, 235, 124.8], [202.305, 235, 124.8],
[204.113, 257.216, 124.8], [209.569, 275.928, 124.8], [218.721, 291.232,
124.8], [231.617, 303.224, 124.8], [248.305, 312, 124.8], [248.305, 312,
124.8], [-1, 312, 124.8]], [[-1, 0, 156], [217.843, 0, 156], [217.843, 235,
156], [217.843, 235, 156], [219.651, 257.216, 156], [225.107, 275.928, 156],
[234.259, 291.232, 156], [247.155, 303.224, 156], [263.843, 312, 156],
[263.843, 312, 156], [-1, 312, 156]], [[-1, 0, 187.2], [230.446, 0, 187.2],
[230.446, 235, 187.2], [230.446, 235, 187.2], [232.254, 257.216, 187.2],
[237.71, 275.928, 187.2], [246.862, 291.232, 187.2], [259.758, 303.224,
187.2], [276.446, 312, 187.2], [276.446, 312, 187.2], [-1, 312, 187.2]],
[[-1, 0, 218.4], [238.665, 0, 218.4], [238.665, 235, 218.4], [238.665, 235,
218.4], [240.473, 257.216, 218.4], [245.929, 275.928, 218.4], [255.081,
291.232, 218.4], [267.977, 303.224, 218.4], [284.665, 312, 218.4], [284.665,
312, 218.4], [-1, 312, 218.4]], [[-1, 0, 249.6], [239.742, 0, 249.6],
[239.742, 235, 249.6], [239.742, 235, 249.6], [241.55, 257.216, 249.6],
[247.006, 275.928, 249.6], [256.158, 291.232, 249.6], [269.054, 303.224,
249.6], [285.742, 312, 249.6], [285.742, 312, 249.6], [-1, 312, 249.6]],
[[-1, 0, 280.8], [226.617, 0, 280.8], [226.617, 235, 280.8], [226.617, 235,
280.8], [228.425, 257.216, 280.8], [233.881, 275.928, 280.8], [243.033,
291.232, 280.8], [255.929, 303.224, 280.8], [272.617, 312, 280.8], [272.617,
312, 280.8], [-1, 312, 280.8]], [[-1, 0, 312], [130.91, 0, 312], [130.91,
235, 312], [130.91, 235, 312], [132.718, 257.216, 312], [138.174, 275.928,
312], [147.326, 291.232, 312], [160.222, 303.224, 312], [176.91, 312, 312],
[176.91, 312, 312], [-1, 312, 312]]];

//      plane_extrude()
//      extrudes a face to make it visible for debugging
module plane_extrude(face, height=1) {
translate([0, 0, face[0][2]])
linear_extrude(height=height)
polygon([for (i=face) [ i[0], i[1] ] ]);
}

// debug
for (i=planes) {
plane_extrude(i);
}

On side note, it would be nice if echo() formatted vectors differently when
they are nested. For example by printing each sub-vector on a new line.

Have a nice day,
Bananapeel :)

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

In pseudo-code: delta=0.1; hull() { for(pt=poly1){ translate(pt) sphere(r=delta); } for(pt=poly2){ translate(pt) sphere(r=delta); } } ...or some variation on that, use hull() to fill the gap. You may have to subdivide your polys into sets of to/from triangle pairs to handle concave regions. Andrew Sent from my iPhone > On Jan 30, 2015, at 2:01 PM, Bananapeel <lunatica.xiaoyu@gmail.com> wrote: > > Hi everyone > > I have a really complex (for me) problem that I can't seem to solve. It is a > subproblem of an attempt to extrude a 2d shape along a bezier curve. > > I have a list of (programmatically generated) polygons stored as vectors, > shown below. > > poly1 = [ > [0,0,0], > [0, 40, 0], > [30, 20, 0], > [50, 30, 0], > [50, 0, 0] > ]; > > poly2 = [ > [0,0,10], > [0, 50, 10], > [30, 30, 10], > [50, 20, 10], > [50, 0, 10] > ]; > > shape = [poly1, poly2, ..., polyN]; > > What I want is to make these into a solid shape. poly1 forms the bottom, > polyN forms the top, the edges of the rest work to define the walls of the > polygons. > > The number of vertices in all polygons is the same, in this example 5 (in > the real world a lot higher). > And the vertices are corresponding (ie the first vertex of first polygon is > to be connected with the first of the second, see below.) The z coordinate > is always the same for all vertices in each polygon. So a list of flat > faces. > > Perhaps a picture makes it more clear. I have drawn in a few triangles in > red and blue. Essentially the whole shape should be covered by them to make > a solid. > > <http://forum.openscad.org/file/n11326/layers.png> > > Code: > > planes = [[[-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [126.808, > 257.216, 0], [132.264, 275.928, 0], [141.416, 291.232, 0], [154.312, > 303.224, 0], [171, 312, 0], [171, 312, 0], [-1, 312, 0]], [[-1, 0, 31.2], > [145.624, 0, 31.2], [145.624, 235, 31.2], [145.624, 235, 31.2], [147.432, > 257.216, 31.2], [152.888, 275.928, 31.2], [162.04, 291.232, 31.2], [174.936, > 303.224, 31.2], [191.624, 312, 31.2], [191.624, 312, 31.2], [-1, 312, > 31.2]], [[-1, 0, 62.4], [165.655, 0, 62.4], [165.655, 235, 62.4], [165.655, > 235, 62.4], [167.463, 257.216, 62.4], [172.919, 275.928, 62.4], [182.071, > 291.232, 62.4], [194.967, 303.224, 62.4], [211.655, 312, 62.4], [211.655, > 312, 62.4], [-1, 312, 62.4]], [[-1, 0, 93.6], [184.703, 0, 93.6], [184.703, > 235, 93.6], [184.703, 235, 93.6], [186.511, 257.216, 93.6], [191.967, > 275.928, 93.6], [201.119, 291.232, 93.6], [214.015, 303.224, 93.6], > [230.703, 312, 93.6], [230.703, 312, 93.6], [-1, 312, 93.6]], [[-1, 0, > 124.8], [202.305, 0, 124.8], [202.305, 235, 124.8], [202.305, 235, 124.8], > [204.113, 257.216, 124.8], [209.569, 275.928, 124.8], [218.721, 291.232, > 124.8], [231.617, 303.224, 124.8], [248.305, 312, 124.8], [248.305, 312, > 124.8], [-1, 312, 124.8]], [[-1, 0, 156], [217.843, 0, 156], [217.843, 235, > 156], [217.843, 235, 156], [219.651, 257.216, 156], [225.107, 275.928, 156], > [234.259, 291.232, 156], [247.155, 303.224, 156], [263.843, 312, 156], > [263.843, 312, 156], [-1, 312, 156]], [[-1, 0, 187.2], [230.446, 0, 187.2], > [230.446, 235, 187.2], [230.446, 235, 187.2], [232.254, 257.216, 187.2], > [237.71, 275.928, 187.2], [246.862, 291.232, 187.2], [259.758, 303.224, > 187.2], [276.446, 312, 187.2], [276.446, 312, 187.2], [-1, 312, 187.2]], > [[-1, 0, 218.4], [238.665, 0, 218.4], [238.665, 235, 218.4], [238.665, 235, > 218.4], [240.473, 257.216, 218.4], [245.929, 275.928, 218.4], [255.081, > 291.232, 218.4], [267.977, 303.224, 218.4], [284.665, 312, 218.4], [284.665, > 312, 218.4], [-1, 312, 218.4]], [[-1, 0, 249.6], [239.742, 0, 249.6], > [239.742, 235, 249.6], [239.742, 235, 249.6], [241.55, 257.216, 249.6], > [247.006, 275.928, 249.6], [256.158, 291.232, 249.6], [269.054, 303.224, > 249.6], [285.742, 312, 249.6], [285.742, 312, 249.6], [-1, 312, 249.6]], > [[-1, 0, 280.8], [226.617, 0, 280.8], [226.617, 235, 280.8], [226.617, 235, > 280.8], [228.425, 257.216, 280.8], [233.881, 275.928, 280.8], [243.033, > 291.232, 280.8], [255.929, 303.224, 280.8], [272.617, 312, 280.8], [272.617, > 312, 280.8], [-1, 312, 280.8]], [[-1, 0, 312], [130.91, 0, 312], [130.91, > 235, 312], [130.91, 235, 312], [132.718, 257.216, 312], [138.174, 275.928, > 312], [147.326, 291.232, 312], [160.222, 303.224, 312], [176.91, 312, 312], > [176.91, 312, 312], [-1, 312, 312]]]; > > // plane_extrude() > // extrudes a face to make it visible for debugging > module plane_extrude(face, height=1) { > translate([0, 0, face[0][2]]) > linear_extrude(height=height) > polygon([for (i=face) [ i[0], i[1] ] ]); > } > > // debug > for (i=planes) { > plane_extrude(i); > } > > > On side note, it would be nice if echo() formatted vectors differently when > they are nested. For example by printing each sub-vector on a new line. > > > Have a nice day, > Bananapeel :) > > > > -- > View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
B
Bananapeel
Fri, Jan 30, 2015 8:49 PM

Splitting up the polygons to handles concave regions was a good idea. Apart
from that that I'm not quite sure what you're suggesting here (I'll take a
closer look). In general I can't use hull() because the polygons are
concave. If I split my polygons into convex regions and use hull() I don't
see where the spheres come in.

:)

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11328.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Splitting up the polygons to handles concave regions was a good idea. Apart from that that I'm not quite sure what you're suggesting here (I'll take a closer look). In general I can't use hull() because the polygons are concave. If I split my polygons into convex regions and use hull() I don't see where the spheres come in. :) -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11328.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
clothbot
Fri, Jan 30, 2015 8:59 PM

Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2), the
following may serve your purpose:

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11329.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2), the following may serve your purpose: -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11329.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AP
Andrew Plumb
Fri, Jan 30, 2015 9:02 PM

...and looks like raw text includes posted from the forum web interface is busted.

Follow the forum post link to see the code.

A.

Sent from my iPhone

On Jan 30, 2015, at 3:59 PM, clothbot andrew@plumb.org wrote:

Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2), the
following may serve your purpose:

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11329.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

...and looks like raw text includes posted from the forum web interface is busted. Follow the forum post link to see the code. A. Sent from my iPhone > On Jan 30, 2015, at 3:59 PM, clothbot <andrew@plumb.org> wrote: > > Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2), the > following may serve your purpose: > > > > > > -- > View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11329.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
B
Bananapeel
Fri, Jan 30, 2015 9:13 PM

I see what you're doing now, and indeed it was my first attempt (except I
used linear extrude() instead of spheres).

It doesn't work with concave objects. And frankly I think subdividing the
polygons is more work than solving the problem directly.

Indeed I had some code for the simplest case (only two polygons "hulled"
together) that I thought was working perfectly, until I tried it on
different polygons and found all the faces to be inside out, and some
structural problems.

Code:

poly1 = [
[0,0,0],
[0, 40,  0],
[30, 20, 0],
[50, 30, 0],
[50, 0, 0]
];

poly2 = [
[0,0,10],
[0, 50,  10],
[30, 30, 10],
[50, 20, 10],
[50, 0, 10]
];

plane1 = [
[-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [125.162,
242.038, 0], [125.65, 248.755, 0], [126.464, 255.154, 0], [127.606, 261.236,
0], [129.077, 267.004, 0], [130.879, 272.461, 0], [133.012, 277.61, 0],
[135.479, 282.453, 0], [138.279, 286.993, 0], [141.416, 291.232, 0],
[144.889, 295.173, 0], [148.701, 298.818, 0], [152.853, 302.171, 0],
[157.345, 305.233, 0], [162.179, 308.008, 0], [167.357, 310.497, 0], [171,
312, 0], [-1, 312, 0]
];

plane2 = [
[-1, 0, 312], [130.91, 0, 312], [130.91, 235, 312], [130.91, 235,
312], [131.073, 242.038, 312], [131.56, 248.755, 312], [132.374, 255.154,
312], [133.516, 261.236, 312], [134.987, 267.004, 312], [136.789, 272.461,
312], [138.922, 277.61, 312], [141.389, 282.453, 312], [144.19, 286.993,
312], [147.326, 291.232, 312], [150.8, 295.173, 312], [154.612, 298.818,
312], [158.763, 302.171, 312], [163.255, 305.233, 312], [168.089, 308.008,
312], [173.267, 310.497, 312], [176.91, 312, 312], [-1, 312, 312]
];

/* pair_mksolid(a, b)
Connect two 3d planes with corresponding vertices into one solid
a: bottom polygon
b: top polygon
/
function pair_mksolid_orange(a, b) = [
concat(a,b), /
add points /
concat( [ /
add planes as faces /
[for (i=[0:len(a)-1]) i],
[for (i=[0:len(b)-1]) i+len(a)]
],
/
divide space between vertex 0 and 1 into two triangles /
/
i is the vertex on plane a, i+len(a) is the corresponding vertex
on plane b */
[for (i=[0:len(a)-1])  [i, (i+1)%len(a), i+len(a)]]
,[for (i=[0:len(a)-2]) [i+1, (i+len(a)+1)%(len(a)*2), i+len(a)]]
,[[0, len(a), len(a)*2-1]]
)
];

   // Simple example almost works (bottom inside out)

poly3d = pair_mksolid_orange(poly1, poly2);
// Complex example does not work (inside out and wrong near
concave-ness)
//poly3d = pair_mksolid_orange(plane1, plane2);
echo(poly3d[0]);
echo("");
echo ( poly3d[1]);
polyhedron(points=poly3d[0], faces=poly3d[1]);

:)

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11331.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I see what you're doing now, and indeed it was my first attempt (except I used linear extrude() instead of spheres). It doesn't work with concave objects. And frankly I think subdividing the polygons is more work than solving the problem directly. Indeed I had some code for the simplest case (only two polygons "hulled" together) that I thought was working perfectly, until I tried it on different polygons and found all the faces to be inside out, and some structural problems. Code: poly1 = [ [0,0,0], [0, 40, 0], [30, 20, 0], [50, 30, 0], [50, 0, 0] ]; poly2 = [ [0,0,10], [0, 50, 10], [30, 30, 10], [50, 20, 10], [50, 0, 10] ]; plane1 = [ [-1, 0, 0], [125, 0, 0], [125, 235, 0], [125, 235, 0], [125.162, 242.038, 0], [125.65, 248.755, 0], [126.464, 255.154, 0], [127.606, 261.236, 0], [129.077, 267.004, 0], [130.879, 272.461, 0], [133.012, 277.61, 0], [135.479, 282.453, 0], [138.279, 286.993, 0], [141.416, 291.232, 0], [144.889, 295.173, 0], [148.701, 298.818, 0], [152.853, 302.171, 0], [157.345, 305.233, 0], [162.179, 308.008, 0], [167.357, 310.497, 0], [171, 312, 0], [-1, 312, 0] ]; plane2 = [ [-1, 0, 312], [130.91, 0, 312], [130.91, 235, 312], [130.91, 235, 312], [131.073, 242.038, 312], [131.56, 248.755, 312], [132.374, 255.154, 312], [133.516, 261.236, 312], [134.987, 267.004, 312], [136.789, 272.461, 312], [138.922, 277.61, 312], [141.389, 282.453, 312], [144.19, 286.993, 312], [147.326, 291.232, 312], [150.8, 295.173, 312], [154.612, 298.818, 312], [158.763, 302.171, 312], [163.255, 305.233, 312], [168.089, 308.008, 312], [173.267, 310.497, 312], [176.91, 312, 312], [-1, 312, 312] ]; /* pair_mksolid(a, b) Connect two 3d planes with corresponding vertices into one solid a: bottom polygon b: top polygon */ function pair_mksolid_orange(a, b) = [ concat(a,b), /* add points */ concat( [ /* add planes as faces */ [for (i=[0:len(a)-1]) i], [for (i=[0:len(b)-1]) i+len(a)] ], /* divide space between vertex 0 and 1 into two triangles */ /* i is the vertex on plane a, i+len(a) is the corresponding vertex on plane b */ [for (i=[0:len(a)-1]) [i, (i+1)%len(a), i+len(a)]] ,[for (i=[0:len(a)-2]) [i+1, (i+len(a)+1)%(len(a)*2), i+len(a)]] ,[[0, len(a), len(a)*2-1]] ) ]; // Simple example almost works (bottom inside out) poly3d = pair_mksolid_orange(poly1, poly2); // Complex example does not work (inside out and wrong near concave-ness) //poly3d = pair_mksolid_orange(plane1, plane2); echo(poly3d[0]); echo(""); echo ( poly3d[1]); polyhedron(points=poly3d[0], faces=poly3d[1]); :) -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11331.html Sent from the OpenSCAD mailing list archive at Nabble.com.
B
Bananapeel
Fri, Jan 30, 2015 9:25 PM

clothbot wrote

Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2),
the following may serve your purpose:

Thanks, that looks almost like what i have, only better, as it fixed the
inside out bottom face.

Either we both made some mistake, or my input polygons are somehow broken
(plane1 and 2 from my previous post).

:)

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11332.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

clothbot wrote > Assuming points are nearest-neighbour ordered and len(poly1)==len(poly2), > the following may serve your purpose: Thanks, that looks almost like what i have, only better, as it fixed the inside out bottom face. Either we both made some mistake, or my input polygons are somehow broken (plane1 and 2 from my previous post). :) -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11332.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Fri, Jan 30, 2015 9:52 PM

clothbot wrote

...and looks like raw text includes posted from the forum web interface is
busted.

That was part of all that testing posts a while ago.It has been partially
fixed, but you need to check the 'Message is in HTML Format' box.I have,
slowly, looked into setting that as default, so far I have found a way for
individuals to set that, but am hoping there is a way to do it for a Nabble
group (or whatever they are called). Nabble's NAML languare is 'different'
and not well documented - if anyone knows a good resource please let me
know. (testing again...)


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11333.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

clothbot wrote > ...and looks like raw text includes posted from the forum web interface is > busted. That was part of all that testing posts a while ago.It has been partially fixed, but you need to check the 'Message is in HTML Format' box.I have, slowly, looked into setting that as default, so far I have found a way for individuals to set that, but am hoping there is a way to do it for a Nabble group (or whatever they are called). Nabble's NAML languare is 'different' and not well documented - if anyone knows a good resource please let me know. (testing again...) ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11333.html Sent from the OpenSCAD mailing list archive at Nabble.com.
B
Bananapeel
Fri, Jan 30, 2015 10:12 PM

Turns out the input data was a little bit broken. All faces clockwise and an
duplicated vertex. However, I still get these mysterious purple "flaps".

http://forum.openscad.org/file/n11334/gullwing.png

Code:

poly1 = [[-1.0,312.0,0.0],
//[171.0,312.0,0.0],
[171.0,312.0,0.0],
[136.375,284.0,0.0],
[125.0,235.0,0.0],
[125.0,235.0,0.0],
[125.0,0.0,0.0],
//[-1.0,0.0,0.0]
];

poly2 = [[-1.0,312.0,30.0],
//[191.624,312.0,30.0],
[191.624,312.0,30.0],
[156.999,284.0,30.0],
[145.624,235.0,30.0],
[145.624,235.0,30.0],
[145.624,0.0,30.0],
//[-1.0,0.0,30.0]
];

for (i=[0:-1+len(poly1)] ) color([1, i0.1, 0]) translate(poly1[i])
sphere(r=5);
for (i=[0:-1+len(poly2)] ) color([0, i
0.1, 1]) translate(poly2[i])
sphere(r=5);

poly1to2=concat(poly1,poly2);
echo(poly1to2);
poly1to2_faces=[ [for(i=[len(poly1)-1:-1:0]) i]
,[for(j=[len(poly1):len(poly1)+len(poly2)-1]) j]
];
poly1to2_faces_between1=[for(k=[0:len(poly1)-1]) [k,k+1,k+len(poly1)]];
poly1to2_faces_between2=[for(k=[0:len(poly1)-1])
[k+len(poly1),k+len(poly1)-1,k]];

echo(poly1to2_faces);
echo(poly1to2_faces_between1);
echo(poly1to2_faces_between2);

polyhedron(points=poly1to2

,faces=concat(poly1to2_faces,poly1to2_faces_between1,poly1to2_faces_between2));

--
View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11334.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Turns out the input data was a little bit broken. All faces clockwise and an duplicated vertex. However, I still get these mysterious purple "flaps". <http://forum.openscad.org/file/n11334/gullwing.png> Code: poly1 = [[-1.0,312.0,0.0], //[171.0,312.0,0.0], [171.0,312.0,0.0], [136.375,284.0,0.0], [125.0,235.0,0.0], [125.0,235.0,0.0], [125.0,0.0,0.0], //[-1.0,0.0,0.0] ]; poly2 = [[-1.0,312.0,30.0], //[191.624,312.0,30.0], [191.624,312.0,30.0], [156.999,284.0,30.0], [145.624,235.0,30.0], [145.624,235.0,30.0], [145.624,0.0,30.0], //[-1.0,0.0,30.0] ]; for (i=[0:-1+len(poly1)] ) color([1, i*0.1, 0]) translate(poly1[i]) sphere(r=5); for (i=[0:-1+len(poly2)] ) color([0, i*0.1, 1]) translate(poly2[i]) sphere(r=5); poly1to2=concat(poly1,poly2); echo(poly1to2); poly1to2_faces=[ [for(i=[len(poly1)-1:-1:0]) i] ,[for(j=[len(poly1):len(poly1)+len(poly2)-1]) j] ]; poly1to2_faces_between1=[for(k=[0:len(poly1)-1]) [k,k+1,k+len(poly1)]]; poly1to2_faces_between2=[for(k=[0:len(poly1)-1]) [k+len(poly1),k+len(poly1)-1,k]]; echo(poly1to2_faces); echo(poly1to2_faces_between1); echo(poly1to2_faces_between2); polyhedron(points=poly1to2 ,faces=concat(poly1to2_faces,poly1to2_faces_between1,poly1to2_faces_between2)); -- View this message in context: http://forum.openscad.org/Connect-planes-with-corresponding-vertices-tp11326p11334.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Fri, Jan 30, 2015 10:35 PM

See https://github.com/openscad/list-comprehension-demos

..and try this:
use <list-comprehension-demos/skin.scad>
skin([poly1,poly2]);

-Marius

See https://github.com/openscad/list-comprehension-demos ..and try this: use <list-comprehension-demos/skin.scad> skin([poly1,poly2]); -Marius