discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fwd: Re: all this talk about ellipses has me a bit confused

RW
Raymond West
Fri, Aug 12, 2022 10:20 AM

Yes,

It merely copies whatever points you start with, and manipulates them
into the three quadrants. It is not designed for specific situations
that may be needed, but if you are considering replicating an oval, say,
with a bulge in it, you only need place points on a quarter of the curve.

On 11/08/2022 20:46, Adrian Mariano wrote:

I didn't double check by actually running the code, but it looks like
that code will create duplicate points if there are points on the x/y
axes. This may not matter...or it might, depending on what you're
going to do with the point list.

In the case of the ellipses, I don't want to end up with two points at
one end that are at, say, [10,1e-12] and [10,-1e-12] or something
like that, so a general implementation would need to test for
approximate equality to zero to avoid creating duplicates.

On Thu, Aug 11, 2022 at 3:35 PM Raymond West raywest@raywest.com wrote:

wrt ovals/ellipse (any list of points in first quadrant), I've put some
code below which will replicate a list of 2d points in the first
quadrant over the other three, in the correct sequence such that it
produces a polygon.

It could probably be made more succinct, but it took me long enough to
get to where it is (not helped by underlining of error messages s;-{ )

// quadrant replication

function reverse(plist)=
[for(j=[0:1:len(plist)-1])plist[len(plist)-1-j]];

// pp1=[[10,100],[50,80],[100,20]]; // test list of points for pp1

pp1 = [[2.77541, 154.533], [30.5096, 154.918], [55.6412, 151.285],
[77.5501, 142.929], [96.0551, 129.467], [111.303, 111.138], [123.428,
88.7918], [132.34, 63.552], [137.786, 36.4907], [139.527, 8.50528]]; //
longer list of points

pp2=[for(p=pp1)([p[0],-p[1]])];

pp2r= reverse(pp2);

pp3=[for(p=pp1)([-p[0],-p[1]])];

pp4=[for(p=pp1)([-p[0],p[1]])];

pp4r=reverse(pp4);

totalshape= concat(pp1,pp2r,pp3,pp4r);

polygon(points=totalshape);


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

Yes, It merely copies whatever points you start with, and manipulates them into the three quadrants. It is not designed for specific situations that may be needed, but if you are considering replicating an oval, say, with a bulge in it, you only need place points on a quarter of the curve. On 11/08/2022 20:46, Adrian Mariano wrote: > I didn't double check by actually running the code, but it looks like > that code will create duplicate points if there are points on the x/y > axes. This may not matter...or it might, depending on what you're > going to do with the point list. > > In the case of the ellipses, I don't want to end up with two points at > one end that are at, say, [10,1e-12] and [10,-1e-12] or something > like that, so a general implementation would need to test for > approximate equality to zero to avoid creating duplicates. > > On Thu, Aug 11, 2022 at 3:35 PM Raymond West <raywest@raywest.com> wrote: >> >> wrt ovals/ellipse (any list of points in first quadrant), I've put some >> code below which will replicate a list of 2d points in the first >> quadrant over the other three, in the correct sequence such that it >> produces a polygon. >> >> It could probably be made more succinct, but it took me long enough to >> get to where it is (not helped by underlining of error messages s;-{ ) >> >> >> // quadrant replication >> >> function reverse(plist)= >> [for(j=[0:1:len(plist)-1])plist[len(plist)-1-j]]; >> >> // pp1=[[10,100],[50,80],[100,20]]; // test list of points for pp1 >> >> pp1 = [[2.77541, 154.533], [30.5096, 154.918], [55.6412, 151.285], >> [77.5501, 142.929], [96.0551, 129.467], [111.303, 111.138], [123.428, >> 88.7918], [132.34, 63.552], [137.786, 36.4907], [139.527, 8.50528]]; // >> longer list of points >> >> pp2=[for(p=pp1)([p[0],-p[1]])]; >> >> pp2r= reverse(pp2); >> >> pp3=[for(p=pp1)([-p[0],-p[1]])]; >> >> pp4=[for(p=pp1)([-p[0],p[1]])]; >> >> pp4r=reverse(pp4); >> >> totalshape= concat(pp1,pp2r,pp3,pp4r); >> >> polygon(points=totalshape); >> >> _______________________________________________ >> 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