### Trying to build a list of points

BR
Bob Roos
Sun, Nov 20, 2022 6:18 AM

I have some points from a parabola that I want to turn into a reflector.  The points are generated from an external program.  Maybe I should be using something in OpenScad to generate them?  I have not explored that yet.

Anyway, I want to generate a 2nd set of points where the X coordinate is a thickness away from the first list so I can have a polygon that I can extrude.

I am aware that what I wrote doesn't work and I understand why it doesn't work, but I have no idea how to make something that will give a list of points.

Bob Roos

// parabolic reflector
// Bob Roos
// November 19, 2022

L1 = [[  0.00,  0.00],[  7.50,  0.39],[  15.00,  1.56],[  22.50,  3.52],[  30.00,  6.25],[  37.50,  9.77],[  45.00, 14.06],[  52.50, 19.14],[  60.00, 25.00],[  67.50, 31.64]];
L3 = [[  75.00, 39.06],[  82.50, 47.27],[  90.00, 56.25],[  97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]];
Thick = 2;

List = concat(L1,L3);
List2 = [];

//rotate_extrude(angle = 360) polygon(List);

for (a =[len(List)-1:-1:0]){
b = List[a][0]+Thick;
List2 = concat(List2,[b,List[a][1]]);
echo(List2);
}

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

Hello OpenSCAD, I have some points from a parabola that I want to turn into a reflector. The points are generated from an external program. Maybe I should be using something in OpenScad to generate them? I have not explored that yet. Anyway, I want to generate a 2nd set of points where the X coordinate is a thickness away from the first list so I can have a polygon that I can extrude. I am aware that what I wrote doesn't work and I understand why it doesn't work, but I have no idea how to make something that will give a list of points. Thank you for your help. Bob Roos // parabolic reflector // Bob Roos // November 19, 2022 L1 = [[ 0.00, 0.00],[ 7.50, 0.39],[ 15.00, 1.56],[ 22.50, 3.52],[ 30.00, 6.25],[ 37.50, 9.77],[ 45.00, 14.06],[ 52.50, 19.14],[ 60.00, 25.00],[ 67.50, 31.64]]; L3 = [[ 75.00, 39.06],[ 82.50, 47.27],[ 90.00, 56.25],[ 97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]]; Thick = 2; List = concat(L1,L3); List2 = []; //rotate_extrude(angle = 360) polygon(List); for (a =[len(List)-1:-1:0]){ b = List[a][0]+Thick; List2 = concat(List2,[b,List[a][1]]); echo(List2); } -- Best regards, Bob mailto:roosbob@wybatap.com
NH
Sun, Nov 20, 2022 6:51 AM

Try this:

List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b,
List[a][1]] ];

You can't modify OpenSCAD variables but list comprehensions allow lists to
be made with for loops. And it would be easy to make a parabolic list in
the same way.

On Sun, 20 Nov 2022 at 06:19, Bob Roos roosbob@wybatap.com wrote:

I have some points from a parabola that I want to turn into a reflector.
The points are generated from an external program.  Maybe I should be using
something in OpenScad to generate them?  I have not explored that yet.

Anyway, I want to generate a 2nd set of points where the X coordinate is a
thickness away from the first list so I can have a polygon that I can
extrude.

I am aware that what I wrote doesn't work and I understand why it doesn't
work, but I have no idea how to make something that will give a list of
points.

Bob Roos

// parabolic reflector
// Bob Roos
// November 19, 2022

L1 = [[  0.00,  0.00],[  7.50,  0.39],[  15.00,  1.56],[  22.50,
3.52],[  30.00,  6.25],[  37.50,  9.77],[  45.00, 14.06],[  52.50,
19.14],[  60.00, 25.00],[  67.50, 31.64]];
L3 = [[  75.00, 39.06],[  82.50, 47.27],[  90.00, 56.25],[  97.50,
66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]];
Thick = 2;

List = concat(L1,L3);
List2 = [];

//rotate_extrude(angle = 360) polygon(List);

for (a =[len(List)-1:-1:0]){
b = List[a][0]+Thick;
List2 = concat(List2,[b,List[a][1]]);
echo(List2);
}

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

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

Try this: List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b, List[a][1]] ]; You can't modify OpenSCAD variables but list comprehensions allow lists to be made with for loops. And it would be easy to make a parabolic list in the same way. On Sun, 20 Nov 2022 at 06:19, Bob Roos <roosbob@wybatap.com> wrote: > Hello OpenSCAD, > > I have some points from a parabola that I want to turn into a reflector. > The points are generated from an external program. Maybe I should be using > something in OpenScad to generate them? I have not explored that yet. > > Anyway, I want to generate a 2nd set of points where the X coordinate is a > thickness away from the first list so I can have a polygon that I can > extrude. > > I am aware that what I wrote doesn't work and I understand why it doesn't > work, but I have no idea how to make something that will give a list of > points. > > Thank you for your help. > > Bob Roos > > // parabolic reflector > // Bob Roos > // November 19, 2022 > > L1 = [[ 0.00, 0.00],[ 7.50, 0.39],[ 15.00, 1.56],[ 22.50, > 3.52],[ 30.00, 6.25],[ 37.50, 9.77],[ 45.00, 14.06],[ 52.50, > 19.14],[ 60.00, 25.00],[ 67.50, 31.64]]; > L3 = [[ 75.00, 39.06],[ 82.50, 47.27],[ 90.00, 56.25],[ 97.50, > 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]]; > Thick = 2; > > List = concat(L1,L3); > List2 = []; > > //rotate_extrude(angle = 360) polygon(List); > > for (a =[len(List)-1:-1:0]){ > b = List[a][0]+Thick; > List2 = concat(List2,[b,List[a][1]]); > echo(List2); > } > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Nov 20, 2022 7:05 AM

On 11/19/2022 10:51 PM, nop head wrote:

Try this:

List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b,
List[a][1]] ];

Code golf!

A little simpler:

offset = [Thick, 0];
List2 = [ for (b = List) b+offset ];

Note that when you do this you need to reverse one of the lists to get
the polygon to wind properly.

function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ];

Putting it all together:

L1 = [[  0.00,  0.00],[  7.50,  0.39],[  15.00,  1.56],[  22.50,  3.52],[  30.00,  6.25],[  37.50,  9.77],[  45.00, 14.06],[  52.50, 19.14],[  60.00, 25.00],[  67.50, 31.64]];
L3 = [[  75.00, 39.06],[  82.50, 47.27],[  90.00, 56.25],[  97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]];
Thick = 2;

function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ];
function offset(a, off) = [ for (b = List) b+off ];

List = concat(L1,L3);
List2 = reverse(offset(List, [Thick, 0]));

polygon(concat(List, List2));

On 11/19/2022 10:51 PM, nop head wrote: > Try this: > > List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b, > List[a][1]] ]; Code golf! A little simpler: offset = [Thick, 0]; List2 = [ for (b = List) b+offset ]; Note that when you do this you need to reverse one of the lists to get the polygon to wind properly. function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ]; --- Putting it all together: L1 = [[ 0.00, 0.00],[ 7.50, 0.39],[ 15.00, 1.56],[ 22.50, 3.52],[ 30.00, 6.25],[ 37.50, 9.77],[ 45.00, 14.06],[ 52.50, 19.14],[ 60.00, 25.00],[ 67.50, 31.64]]; L3 = [[ 75.00, 39.06],[ 82.50, 47.27],[ 90.00, 56.25],[ 97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]]; Thick = 2; function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ]; function offset(a, off) = [ for (b = List) b+off ]; List = concat(L1,L3); List2 = reverse(offset(List, [Thick, 0])); polygon(concat(List, List2));
JB
Jordan Brown
Sun, Nov 20, 2022 7:11 AM

Also note that offsetting in X alone doesn't really do what you want,
because at the start of the curve it's close to Y=0 and the result is
thin; it's only when the curve goes vertical that you get a thickness of 2.

Better might be to offset it by [2,-2]:

but that isn't exactly right either:

Getting it truly right is, I believe, a bit of an adventure.

Also note that offsetting in X alone doesn't really do what you want, because at the start of the curve it's close to Y=0 and the result is thin; it's only when the curve goes vertical that you get a thickness of 2. Better might be to offset it by [2,-2]:  but that isn't exactly right either: Getting it truly right is, I believe, a bit of an adventure.
AC
Andy Cole
Sun, Nov 20, 2022 7:21 AM

Hi Bob

I try to use low tech solutions because I am not a programmer or good at
math, and am getting old.

I generate a spreadsheet with a parabolic function(y = x2) with a small
offset added, plot it on a chart, export as an image, put it in LibreCAD,
trace it, and import it into OpenSCAD as a .dxf file.

I won't be offended if you don't like it.

Andy

On Sun, 20 Nov 2022 at 16:18, Bob Roos roosbob@wybatap.com wrote:

I have some points from a parabola that I want to turn into a reflector.
The points are generated from an external program.  Maybe I should be using
something in OpenScad to generate them?  I have not explored that yet.

Anyway, I want to generate a 2nd set of points where the X coordinate is a
thickness away from the first list so I can have a polygon that I can
extrude.

I am aware that what I wrote doesn't work and I understand why it doesn't
work, but I have no idea how to make something that will give a list of
points.

Bob Roos

// parabolic reflector
// Bob Roos
// November 19, 2022

L1 = [[  0.00,  0.00],[  7.50,  0.39],[  15.00,  1.56],[  22.50,
3.52],[  30.00,  6.25],[  37.50,  9.77],[  45.00, 14.06],[  52.50,
19.14],[  60.00, 25.00],[  67.50, 31.64]];
L3 = [[  75.00, 39.06],[  82.50, 47.27],[  90.00, 56.25],[  97.50,
66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]];
Thick = 2;

List = concat(L1,L3);
List2 = [];

//rotate_extrude(angle = 360) polygon(List);

for (a =[len(List)-1:-1:0]){
b = List[a][0]+Thick;
List2 = concat(List2,[b,List[a][1]]);
echo(List2);
}

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

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

Hi Bob I try to use low tech solutions because I am not a programmer or good at math, and am getting old. I generate a spreadsheet with a parabolic function(y = x2) with a small offset added, plot it on a chart, export as an image, put it in LibreCAD, trace it, and import it into OpenSCAD as a .dxf file. I won't be offended if you don't like it. Andy On Sun, 20 Nov 2022 at 16:18, Bob Roos <roosbob@wybatap.com> wrote: > Hello OpenSCAD, > > I have some points from a parabola that I want to turn into a reflector. > The points are generated from an external program. Maybe I should be using > something in OpenScad to generate them? I have not explored that yet. > > Anyway, I want to generate a 2nd set of points where the X coordinate is a > thickness away from the first list so I can have a polygon that I can > extrude. > > I am aware that what I wrote doesn't work and I understand why it doesn't > work, but I have no idea how to make something that will give a list of > points. > > Thank you for your help. > > Bob Roos > > // parabolic reflector > // Bob Roos > // November 19, 2022 > > L1 = [[ 0.00, 0.00],[ 7.50, 0.39],[ 15.00, 1.56],[ 22.50, > 3.52],[ 30.00, 6.25],[ 37.50, 9.77],[ 45.00, 14.06],[ 52.50, > 19.14],[ 60.00, 25.00],[ 67.50, 31.64]]; > L3 = [[ 75.00, 39.06],[ 82.50, 47.27],[ 90.00, 56.25],[ 97.50, > 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]]; > Thick = 2; > > List = concat(L1,L3); > List2 = []; > > //rotate_extrude(angle = 360) polygon(List); > > for (a =[len(List)-1:-1:0]){ > b = List[a][0]+Thick; > List2 = concat(List2,[b,List[a][1]]); > echo(List2); > } > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Nov 20, 2022 8:05 AM

Here's generating your original curve, give or take a couple of thousandths:

List = [ for (x = [0 : 7.5 : 120]) [ x, x*x/144 ] ];

Here's generating your original curve, give or take a couple of thousandths: List = [ for (x = [0 : 7.5 : 120]) [ x, x*x/144 ] ];
NH
Sun, Nov 20, 2022 8:10 AM

Perhaps make the thickness very small and then use offset() to give it
proper thickness. That way the width variation with gradient would be very
small.

On Sun, 20 Nov 2022 at 08:06, Jordan Brown openscad@jordan.maileater.net
wrote:

Here's generating your original curve, give or take a couple of
thousandths:

List = [ for (x = [0 : 7.5 : 120]) [ x, x*x/144 ] ];

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

Perhaps make the thickness very small and then use offset() to give it proper thickness. That way the width variation with gradient would be very small. On Sun, 20 Nov 2022 at 08:06, Jordan Brown <openscad@jordan.maileater.net> wrote: > Here's generating your original curve, give or take a couple of > thousandths: > > List = [ for (x = [0 : 7.5 : 120]) [ x, x*x/144 ] ]; > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GH
gene heskett
Sun, Nov 20, 2022 8:27 AM

On 11/20/22 02:05, Jordan Brown wrote:

On 11/19/2022 10:51 PM, nop head wrote:

Try this:

List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b,
List[a][1]] ];

Code golf!

A little simpler:

offset = [Thick, 0];
List2 = [ for (b = List) b+offset ];

Note that when you do this you need to reverse one of the lists to get
the polygon to wind properly.

function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ];

Putting it all together:

L1 = [[  0.00,  0.00],[  7.50,  0.39],[  15.00,  1.56],[  22.50,  3.52],[  30.00,  6.25],[  37.50,  9.77],[  45.00, 14.06],[  52.50, 19.14],[  60.00, 25.00],[  67.50, 31.64]];
L3 = [[  75.00, 39.06],[  82.50, 47.27],[  90.00, 56.25],[  97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]];
Thick = 2;

function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ];
function offset(a, off) = [ for (b = List) b+off ];

List = concat(L1,L3);
List2 = reverse(offset(List, [Thick, 0]));

polygon(concat(List, List2));

I am math challenged, only an 8th grade education, but this sort of a
problem would seem to be right up the "polar math" alley. The path
interpreter as used in LinuxCNC can take not only a trio of points
(actually 9 points) as the goto command, but can also work with distance
from an anchoring point and an angle from that point and can then draw
arbitrary curves from a list of distances and angles.

I think that it is in the RS-274-D spec.

I don't see that polar math ability in OpenSCAD unless its hiding under
a different name.

Is it?

And it is submicron accurate even in 3d space. The accuracy limit is the
mechanical limits of the machine it is controlling. Screw and gear
backlash are the real accuracy limits.

A bit off-topic, but...

Mapping that wear out of a worn machine will challenge your measuring
tools accuracy but can be done. I'm doing it on an 80 yo Sheldon lathe
whose bed is worn down about 23 thou right in front of the chuck, but it
carves long cylinders to a thou accuracy now. And I'm doing it with an
rpi4b running LinuxCNC. And I did it just to see if I could, 1st on this
ball of rock and water with an rpi3b.

## Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

On 11/20/22 02:05, Jordan Brown wrote: > On 11/19/2022 10:51 PM, nop head wrote: >> Try this: >> >> List2 = [for(a =[len(List)-1:-1:0]) let( b = List[a][0]+Thick) [b, >> List[a][1]] ]; > > Code golf! > > A little simpler: > > offset = [Thick, 0]; > List2 = [ for (b = List) b+offset ]; > > Note that when you do this you need to reverse one of the lists to get > the polygon to wind properly. > > function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ]; > > --- > > Putting it all together: > > L1 = [[ 0.00, 0.00],[ 7.50, 0.39],[ 15.00, 1.56],[ 22.50, 3.52],[ 30.00, 6.25],[ 37.50, 9.77],[ 45.00, 14.06],[ 52.50, 19.14],[ 60.00, 25.00],[ 67.50, 31.64]]; > L3 = [[ 75.00, 39.06],[ 82.50, 47.27],[ 90.00, 56.25],[ 97.50, 66.02],[ 105.00, 76.56],[ 112.50, 87.89],[ 120.00,100.00]]; > Thick = 2; > > function reverse(a) = [ for (i = [len(a)-1:-1:0]) a[i] ]; > function offset(a, off) = [ for (b = List) b+off ]; > > List = concat(L1,L3); > List2 = reverse(offset(List, [Thick, 0])); > > polygon(concat(List, List2)); > > I am math challenged, only an 8th grade education, but this sort of a problem would seem to be right up the "polar math" alley. The path interpreter as used in LinuxCNC can take not only a trio of points (actually 9 points) as the goto command, but can also work with distance from an anchoring point and an angle from that point and can then draw arbitrary curves from a list of distances and angles. I think that it is in the RS-274-D spec. I don't see that polar math ability in OpenSCAD unless its hiding under a different name. Is it? And it is submicron accurate even in 3d space. The accuracy limit is the mechanical limits of the machine it is controlling. Screw and gear backlash are the real accuracy limits. A bit off-topic, but... Mapping that wear out of a worn machine will challenge your measuring tools accuracy but can be done. I'm doing it on an 80 yo Sheldon lathe whose bed is worn down about 23 thou right in front of the chuck, but it carves long cylinders to a thou accuracy now. And I'm doing it with an rpi4b running LinuxCNC. And I did it just to see if I could, 1st on this ball of rock and water with an rpi3b. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/>
BR
Bob Roos
Sun, Nov 20, 2022 8:57 AM

Hi Jordan,

I knew the bottom point would be off and was planning on adding a [0,-Thick] at the bottom to take care of that.

THANK YOU all for the suggestions.  I learned a lot from this adventure.  The reflector is for low grade audio recording so I don't need super accuracy.

Bob

Sunday, November 20, 2022, 2:11:20 AM, you wrote:

Also note that offsetting in X alone doesn't really do what you want, because at the start of the curve it's close to Y=0 and the result is thin; it's only when the curve goes vertical that you get a thickness of 2.

Better might be to offset it by [2,-2]:

but that isn't exactly right either:

Getting it truly right is, I believe, a bit of an adventure.

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

Hi Jordan,   I knew the bottom point would be off and was planning on adding a [0,-Thick] at the bottom to take care of that.   THANK YOU all for the suggestions.  I learned a lot from this adventure.  The reflector is for low grade audio recording so I don't need super accuracy.   Bob Sunday, November 20, 2022, 2:11:20 AM, you wrote: > Also note that offsetting in X alone doesn't really do what you want, because at the start of the curve it's close to Y=0 and the result is thin; it's only when the curve goes vertical that you get a thickness of 2. > Better might be to offset it by [2,-2]: >  but that isn't exactly right either: > Getting it truly right is, I believe, a bit of an adventure. --  have Fun,  Bob                           mailto:roosbob@wybatap.com
BR
Bob Roos
Sun, Nov 20, 2022 9:20 AM

Hi Bob,

Looks good in OPenSCAD but you can't see cross section until you slice it.  It was tough to get one layer at the top when printed upside down.

Will try offset.  Thanks again.

Bob

Sunday, November 20, 2022, 3:57:55 AM, you wrote:

Hi Jordan,

I knew the bottom point would be off and was planning on adding a [0,-Thick] at the bottom to take care of that.

THANK YOU all for the suggestions.  I learned a lot from this adventure.  The reflector is for low grade audio recording so I don't need super accuracy.

Bob

Sunday, November 20, 2022, 2:11:20 AM, you wrote:

Also note that offsetting in X alone doesn't really do what you want, because at the start of the curve it's close to Y=0 and the result is thin; it's only when the curve goes vertical that you get a thickness of 2.

Better might be to offset it by [2,-2]:

but that isn't exactly right either:

Getting it truly right is, I believe, a bit of an adventure.

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

Hi Bob, Looks good in OPenSCAD but you can't see cross section until you slice it.  It was tough to get one layer at the top when printed upside down.   Will try offset.  Thanks again.   Bob Sunday, November 20, 2022, 3:57:55 AM, you wrote: > Hi Jordan, >   > I knew the bottom point would be off and was planning on adding a [0,-Thick] at the bottom to take care of that. >   > THANK YOU all for the suggestions.  I learned a lot from this adventure.  The reflector is for low grade audio recording so I don't need super accuracy. >   > Bob > Sunday, November 20, 2022, 2:11:20 AM, you wrote: >> Also note that offsetting in X alone doesn't really do what you want, because at the start of the curve it's close to Y=0 and the result is thin; it's only when the curve goes vertical that you get a thickness of 2. >> Better might be to offset it by [2,-2]: >>  but that isn't exactly right either: >> Getting it truly right is, I believe, a bit of an adventure. --  have Fun,  Bob                           mailto:roosbob@wybatap.com