I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
I use a function that given, a list of 2D points, a polygon, returns a list
of 3 d points, where the Z coordinate is a constant or the result of a
simple function.
I have a function that, given two such lists of 3D points, marches around
the lists, using a pair from list A, and a pair from list B, generating the
edge list that polyhedron() needs, then it appends the polygons-in-3space
as end caps, making a valid OpenSCAD polyhedron.
This kind of thing (not exactly what you want, but close.):
// Schwarz Lantern https://www.youtube.com/watch?v=yAEveAH2KwI
// by David Phillip Oster 12/27/2023
// Creates a generalized cylinder by lacing up with triangles
// parallel bands, each with the same number of vertices.
// In this example, the vertices in each band are equi-spaced along
circles, each the same size
// but they could be almost a series of almost any shape as long as the
vertices line up.
// number of bands
b=14; // [1:20]
// number of vertices
p=3; // [3:20]
// height in mm
h = 100;
// diameter in mm
d = 100;
// vertices: each band is offset from the previous by half the distance
between vertices
pts = [for(y=[0:b], i=[0:p-1]) [(d/2)*sin(360*(i + (y%2)/2)/p),
(d/2)cos(360(i + (y%2)/2)/p), y*h/b]];
// indices of top face
top = [for(i=[p-1:-1:0]) i];
// indices of bottom face
bottom = [for(i=[p-1:-1:0]) len(pts) - i - 1];
// walls are 0,1 from bottom, 1, from top, then advance both by 1,
modulo len.
walls0 = [for(y=[0:b-1], i=[0:p-1]) let(off=y*p,
inc=(y%2)?1:0)[off+(i%p), off+(i+1)%p, off+p+((i+inc)%p)] ];
walls1 = [for(y=[0:b-1], i=[0:p-1]) let(off=y*p,
inc=(y%2)?p:1)[off+p+(i%p), off+(i+inc)%p, off+p+((i+1)%p)] ];
// Concatenate two lists.
function cat(L1, L2) = [for(L=[L1, L2], a=L) a];
polyhedron(points=pts, faces= cat(cat([top, bottom], walls0), walls1) );
On Mon, Jul 1, 2024 at 7:13 PM Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
dont be embarrased, its not so simple at all.
I wrote a function which can do this.
here is the function with an example
function faces(sol)=
// calculate the faces for the vertices with shape l x m with first and
the last end closed
let(
l=len(sol),
m=len(sol[0]),
n1=[for(i=[0:m-1])i],
n2=[for(i=[0:l-2]) each ([ for(j=[0:m-1])
each
j<m-1?[[(j+1)+im,j+im,j+(i+1)m],[(j+1)+im,j+(i+1)m,(j+1)+(i+1)m]]:
[[0+im,j+im,j+(i+1)m],[0+im,j+(i+1)*m,0+(i+1)*m]]
])],
n3=[for(i=[0:m-1])i+(l-1)*m],
n4=[for(i=[len(n3)-1:-1:0])n3[i]],
n=[n1,each (n2),n4]
)n;
function vertices(sol)=
[each for (p=sol)p];
// module for rendering the polyhedron with ends closed
module swp(sol){
let(
v1=vertices(sol),
f1=faces(sol)
)
polyhedron(v1,f1,convexity=10);
}
r=10;
r1=8;
r2=5;
n=10;
a=[for(i=[-360/n/4:360/n/2:360]) [rcos(i),rsin(i),0] ];
b=[for(i=[0:360/n:360])[r1cos(i),r1sin(i)]];
c=[for(i=[360/n/2:360/n:360+360/n])[r2cos(i),r2sin(i)]];
d=[for(i=[0:len(b)-1])each([[b[i].x,b[i].y,10],[c[i].x,c[i].y,10]])];
swp([a,d]);
On Tue, 2 Jul 2024 at 07:43, Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
You have to use polyhedron() to do that. I personally think that using
polyhedron() directly is a recipe for frustration and wasted time. Use a
library. BOSL2 has vnf_vertex_array() and skin() that can do this. They
will both do exactly what you want. The skin() function can help if the
vertices aren't indexed into the best alignment between the polygons, and
does also attempt to address the case where the vertex count of the two
polygons is not the same.
On Mon, Jul 1, 2024 at 10:13 PM Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Adrian:
Thank you. Is there any chance that BOSL2 over-rides the native
offset() function? I am now getting error messages for offset(). I
could not find an offset() defined in BOSL2. Puzzling.
Jon
On 7/2/2024 12:02 AM, Adrian Mariano via Discuss wrote:
You have to use polyhedron() to do that. I personally think that
using polyhedron() directly is a recipe for frustration and wasted
time. Use a library. BOSL2 has vnf_vertex_array() and skin() that
can do this. They will both do exactly what you want. The skin()
function can help if the vertices aren't indexed into the best
alignment between the polygons, and does also attempt to address the
case where the vertex count of the two polygons is not the same.
On Mon, Jul 1, 2024 at 10:13 PM Jon Bondy via Discuss
discuss@lists.openscad.org wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly
different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which
hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com <http://www.avg.com>
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Never mind. It is not the offset(). The documentation for skin() says it takes a "profile", but I gather that a polygon() is not a profile:
include <BOSL2/std.scad>
module Shape()
skin(
[
// offset(4)
// offset(-4)
polygon([
[0, 0], // 1
[9.4, 0], // 2
[9.4 + 4.1 , -9.4], // 3
[9.4 + 4.1 + 21.3 , -9.4], // 4
[9.4 + 4.1 + 21.3 + 4.1 , 0], // 5
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 0], // 6
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 28.5], // 7
[9.4 + 4.1 + 21.3 + 4.1 , 28.5], // 8
[9.4 + 4.1 + 21.3 , 28.5 + 9.4], // 9
[9.4 + 4.1 , 28.5 + 9.4], // 10
[9.4 , 28.5], // 11
[0 , 28.5] // 12
]),
// offset(4)
// offset(-4)
polygon([
[0, 0], // 1
[9.4, 0], // 2
[9.4 + 4.1 , -9.4], // 3
[9.4 + 4.1 + 21.3 , -9.4], // 4
[9.4 + 4.1 + 21.3 + 4.1 , 0], // 5
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 0], // 6
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 33.1], // 7
[9.4 + 4.1 + 21.3 + 4.1 , 33.1], // 8
[9.4 + 4.1 + 21.3 , 33.1 + 9.4], // 9
[9.4 + 4.1 , 33.1 + 9.4], // 10
[9.4 , 33.1], // 11
[0 , 33.1] // 12
])
], z = [0, 36.3], slices=2);
!Shape();
On 7/2/2024 7:07 AM, Jon Bondy via Discuss wrote:
Adrian:
Thank you. Is there any chance that BOSL2 over-rides the native offset() function? I am now getting error messages for offset(). I could not find an offset() defined in BOSL2. Puzzling.
Jon
On 7/2/2024 12:02 AM, Adrian Mariano via Discuss wrote:
You have to use polyhedron() to do that. I personally think that using polyhedron() directly is a recipe for frustration and wasted time. Use a library. BOSL2 has vnf_vertex_array() and skin() that can do this. They will both do exactly what you want. The skin() function can help if the vertices aren't indexed into the best alignment between the polygons, and does also attempt to address the case where the vertex count of the two polygons is not the same.
On Mon, Jul 1, 2024 at 10:13 PM Jon Bondy via Discuss <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.comhttp://www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
[https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-green-avg-v1.png]http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient Virus-free.www.avg.comhttp://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
Never mind, again. Removing the polygon() and just using the point list works.
Sorry for all of the flailing.
Jon
On 7/2/2024 7:18 AM, jon jonbondy.com via Discuss wrote:
Never mind. It is not the offset(). The documentation for skin() says it takes a "profile", but I gather that a polygon() is not a profile:
include <BOSL2/std.scad>
module Shape()
skin(
[
// offset(4)
// offset(-4)
polygon([
[0, 0], // 1
[9.4, 0], // 2
[9.4 + 4.1 , -9.4], // 3
[9.4 + 4.1 + 21.3 , -9.4], // 4
[9.4 + 4.1 + 21.3 + 4.1 , 0], // 5
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 0], // 6
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 28.5], // 7
[9.4 + 4.1 + 21.3 + 4.1 , 28.5], // 8
[9.4 + 4.1 + 21.3 , 28.5 + 9.4], // 9
[9.4 + 4.1 , 28.5 + 9.4], // 10
[9.4 , 28.5], // 11
[0 , 28.5] // 12
]),
// offset(4)
// offset(-4)
polygon([
[0, 0], // 1
[9.4, 0], // 2
[9.4 + 4.1 , -9.4], // 3
[9.4 + 4.1 + 21.3 , -9.4], // 4
[9.4 + 4.1 + 21.3 + 4.1 , 0], // 5
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 0], // 6
[9.4 + 4.1 + 21.3 + 4.1 + 9.4, 33.1], // 7
[9.4 + 4.1 + 21.3 + 4.1 , 33.1], // 8
[9.4 + 4.1 + 21.3 , 33.1 + 9.4], // 9
[9.4 + 4.1 , 33.1 + 9.4], // 10
[9.4 , 33.1], // 11
[0 , 33.1] // 12
])
], z = [0, 36.3], slices=2);
!Shape();
On 7/2/2024 7:07 AM, Jon Bondy via Discuss wrote:
Adrian:
Thank you. Is there any chance that BOSL2 over-rides the native offset() function? I am now getting error messages for offset(). I could not find an offset() defined in BOSL2. Puzzling.
Jon
On 7/2/2024 12:02 AM, Adrian Mariano via Discuss wrote:
You have to use polyhedron() to do that. I personally think that using polyhedron() directly is a recipe for frustration and wasted time. Use a library. BOSL2 has vnf_vertex_array() and skin() that can do this. They will both do exactly what you want. The skin() function can help if the vertices aren't indexed into the best alignment between the polygons, and does also attempt to address the case where the vertex count of the two polygons is not the same.
On Mon, Jul 1, 2024 at 10:13 PM Jon Bondy via Discuss <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.comhttp://www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
[https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-green-avg-v1.png]http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient Virus-free.www.avg.comhttp://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org
There is no offset() function in native OpenSCAD, only the offset()
module. BOSL2 supplies the offset() function, which you'll want to use
(with closed=true), but does not change the module. It looks like you
have the same point list, differently offset. You generally only need
slices>0 if there is twisting, so you might check if the larger value makes
a different. (If it does, 2 is probably not large enough.)
On Tue, Jul 2, 2024 at 7:07 AM Jon Bondy jon@jonbondy.com wrote:
Adrian:
Thank you. Is there any chance that BOSL2 over-rides the native offset()
function? I am now getting error messages for offset(). I could not find
an offset() defined in BOSL2. Puzzling.
Jon
On 7/2/2024 12:02 AM, Adrian Mariano via Discuss wrote:
You have to use polyhedron() to do that. I personally think that using
polyhedron() directly is a recipe for frustration and wasted time. Use a
library. BOSL2 has vnf_vertex_array() and skin() that can do this. They
will both do exactly what you want. The skin() function can help if the
vertices aren't indexed into the best alignment between the polygons, and
does also attempt to address the case where the vertex count of the two
polygons is not the same.
On Mon, Jul 1, 2024 at 10:13 PM Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:
I'm sure I will be embarrassed at how simple this is, but.
Given two polygons with equal number of points, but slightly different
shape, how can I make a solid with one on the bottom and the other on
the top. I tried hull(), but the shapes have concavities which hull()
destroys.
It feels like it is a very simple (almost trivial) skin()
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
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
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
Virus-free.www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
<#m_3170643429425814731_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
I got there, eventually, after a LOT of flailing. Clearly, I do not understand the difference between a list of numbers, a function() that returns a list of numbers, a module() that returns a list of numbers, and the result of applying polygon() or offset() to any of the above. It took a lot of trial-and-error to get what I wanted, all attributable to my lack of understanding the representations under the hood for each of these objects.
Jon
On 7/2/2024 8:26 AM, Adrian Mariano wrote:
There is no offset() function in native OpenSCAD, only the offset() module. BOSL2 supplies the offset() function, which you'll want to use (with closed=true), but does not change the module. It looks like you have the same point list, differently offset. You generally only need slices>0 if there is twisting, so you might check if the larger value makes a different. (If it does, 2 is probably not large enough.)
On Tue, 2024-07-02 at 13:06 +0000, jon jonbondy.com via Discuss wrote:
I got there, eventually, after a LOT of flailing. Clearly, I do not
understand the difference between a list of numbers, a function()
that returns a list of numbers, a module() that returns a list of
numbers, and the result of applying polygon() or offset() to any of
the above. It took a lot of trial-and-error to get what I wanted,
all attributable to my lack of understanding the representations
under the hood for each of these objects.
Jon
I'd be interested in the final code, if you are willing to share it.
On 7/2/2024 8:26 AM, Adrian Mariano wrote:
There is no offset() function in native OpenSCAD, only the offset()
module. BOSL2 supplies the offset() function, which you'll want to
use (with closed=true), but does not change the module. It looks
like you have the same point list, differently offset. You
generally only need slices>0 if there is twisting, so you might
check if the larger value makes a different. (If it does, 2 is
probably not large enough.)
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org