discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Restrictions on functions and modules or .other alternative

NH
nop head
Tue, Mar 29, 2022 12:28 PM

You can join lists with concat().

polygon(concat(points1, points2));

On Tue, 29 Mar 2022 at 11:06, Jan Öhman via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: "Jan Öhman" jan_ohman@yahoo.com
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 29 Mar 2022 10:00:25 +0000 (UTC)
Subject: [OpenSCAD] Re: Restrictions on functions and modules or .other
alternative
thank you!
this is exactly what I was looking for - almost ...
This program (at the bottom) Is a bit modified towards the presented
solution and creates two number series with coordinates.

But, how to combine several series? (this doesn't work)
points1 =
[[10, 10], [10, -0.0197717], [8.74419, 0.0592372], [7.50818, 0.295018],
[6.31148, 0.683852], [5.17294, 1.21961], [4.11053, 1.89383], [3.14099,
2.6959], [2.27963, 3.61316], [1.54003, 4.63114], [0.933839, 5.73379],
[0.470631, 6.90372], [0.157706, 8.12248], [0, 9.37085]]

points2 =
[[10, 50], [-0.0197717, 50], [0.0592372, 51.2558], [0.295018, 52.4918],
[0.683852, 53.6885], [1.21961, 54.8271], [1.89383, 55.8895], [2.6959,
56.859], [3.61316, 57.7204], [4.63114, 58.46], [5.73379, 59.0662],
[6.90372, 59.5294], [8.12248, 59.8423], [9.37085, 60]]

polygon(points1, points2);

This instructions works as desire .:
points =
[[10, -0.0197717], [8.74419, 0.0592372], [7.50818, 0.295018], [6.31148,
0.683852], [5.17294, 1.21961], [4.11053, 1.89383], [3.14099, 2.6959],
[2.27963, 3.61316], [1.54003, 4.63114], [0.933839, 5.73379], [0.470631,
6.90372], [0.157706, 8.12248], [0, 9.37085],

 [-0.0197717, 50], [0.0592372, 51.2558], [0.295018, 52.4918],

[0.683852, 53.6885], [1.21961, 54.8271], [1.89383, 55.8895], [2.6959,
56.859], [3.61316, 57.7204], [4.63114, 58.46], [5.73379, 59.0662],
[6.90372, 59.5294], [8.12248, 59.8423], [9.37085, 60]];

polygon(points);

My program below

fn = 50;
radius1 = 10;
angles1 = [0, 90];
rotate1 = 1;      // 1 medurs, -1 moturs
startAngel1 = "bottom";
x1 = 10;
y1 = 10;

// points1 = circSect();
points1 = circSect(x1, y1, radius1, angles1, startAngel1, rotate1, fn);
polygon(points1);

points2 = circSect(10, 50, 10, [0, 90], "left", 1, fn);
polygon(points2);

function circSect(x=0, y=0, radius=10, angles=[0,270], startRef="bottom",
rotate=1, fn=24)  =
let(
startAngel  = (startRef == "left")  ?  0
: (startRef == "bottom") ?  90
: (startRef == "right")  ? 180
: (startRef == "top")    ? 270
: undef,

     r = radius / cos(180 / fn),
     step = 360 / fn,
     points = [[x, y],
         for(a = [angles[0]-startAngel : step : angles[1]-startAngel])
             [-rotate * r * cos(a)+x, r * sin(a)+y]]
 ) points;

Den måndag 28 mars 2022 18:39:37 CEST, Jordan Brown <
openscad@jordan.maileater.net> skrev:

On 3/27/2022 5:23 PM, nop head wrote:

function sector(radius, angles, fn = 24)  =
let(
r = radius / cos(180 / fn),
step = -360 / fn,
points = concat([[0, 0]],
[for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)]
],
[[r * cos(angles[1]), r * sin(angles[1])]]
)
) points;

radius = 10;
angles = [0, 90];

echo(sector(radius, angles));

Simplifying a little - the concat isn't necessary; you can just directly
create the list:

function sector(radius, angles, fn = 24)  =
let(
r = radius / cos(180 / fn),
step = -360 / fn,
points = [
[0, 0],
for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)],
[r * cos(angles[1]), r * sin(angles[1])]
]
) points;

radius = 10;
angles = [0, 90];

echo(sector(radius, angles));


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

---------- Forwarded message ----------
From: "Jan Öhman via Discuss" discuss@lists.openscad.org
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: "Jan Öhman" jan_ohman@yahoo.com
Bcc:
Date: Tue, 29 Mar 2022 10:00:25 +0000 (UTC)
Subject: [OpenSCAD] Re: Restrictions on functions and modules or .other
alternative


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

You can join lists with concat(). *polygon(concat(points1, points2));* On Tue, 29 Mar 2022 at 11:06, Jan Öhman via Discuss < discuss@lists.openscad.org> wrote: > > > > ---------- Forwarded message ---------- > From: "Jan Öhman" <jan_ohman@yahoo.com> > To: OpenSCAD general discussion <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Tue, 29 Mar 2022 10:00:25 +0000 (UTC) > Subject: [OpenSCAD] Re: Restrictions on functions and modules or .other > alternative > thank you! > this is exactly what I was looking for - almost ... > This program (at the bottom) Is a bit modified towards the presented > solution and creates two number series with coordinates. > > But, how to combine several series? (this doesn't work) > points1 = > [[10, 10], [10, -0.0197717], [8.74419, 0.0592372], [7.50818, 0.295018], > [6.31148, 0.683852], [5.17294, 1.21961], [4.11053, 1.89383], [3.14099, > 2.6959], [2.27963, 3.61316], [1.54003, 4.63114], [0.933839, 5.73379], > [0.470631, 6.90372], [0.157706, 8.12248], [0, 9.37085]] > > points2 = > [[10, 50], [-0.0197717, 50], [0.0592372, 51.2558], [0.295018, 52.4918], > [0.683852, 53.6885], [1.21961, 54.8271], [1.89383, 55.8895], [2.6959, > 56.859], [3.61316, 57.7204], [4.63114, 58.46], [5.73379, 59.0662], > [6.90372, 59.5294], [8.12248, 59.8423], [9.37085, 60]] > > *polygon(points1, points2);* > > This instructions works as desire .: > points = > [[10, -0.0197717], [8.74419, 0.0592372], [7.50818, 0.295018], [6.31148, > 0.683852], [5.17294, 1.21961], [4.11053, 1.89383], [3.14099, 2.6959], > [2.27963, 3.61316], [1.54003, 4.63114], [0.933839, 5.73379], [0.470631, > 6.90372], [0.157706, 8.12248], [0, 9.37085], > > [-0.0197717, 50], [0.0592372, 51.2558], [0.295018, 52.4918], > [0.683852, 53.6885], [1.21961, 54.8271], [1.89383, 55.8895], [2.6959, > 56.859], [3.61316, 57.7204], [4.63114, 58.46], [5.73379, 59.0662], > [6.90372, 59.5294], [8.12248, 59.8423], [9.37085, 60]]; > > polygon(points); > > > My program below > > fn = 50; > radius1 = 10; > angles1 = [0, 90]; > rotate1 = 1; // 1 medurs, -1 moturs > startAngel1 = "bottom"; > x1 = 10; > y1 = 10; > > // points1 = circSect(); > points1 = circSect(x1, y1, radius1, angles1, startAngel1, rotate1, fn); > polygon(points1); > > > points2 = circSect(10, 50, 10, [0, 90], "left", 1, fn); > polygon(points2); > > > function circSect(x=0, y=0, radius=10, angles=[0,270], startRef="bottom", > rotate=1, fn=24) = > let( > startAngel = (startRef == "left") ? 0 > : (startRef == "bottom") ? 90 > : (startRef == "right") ? 180 > : (startRef == "top") ? 270 > : undef, > > r = radius / cos(180 / fn), > step = 360 / fn, > points = [[x, y], > for(a = [angles[0]-startAngel : step : angles[1]-startAngel]) > [-rotate * r * cos(a)+x, r * sin(a)+y]] > ) points; > > > Den måndag 28 mars 2022 18:39:37 CEST, Jordan Brown < > openscad@jordan.maileater.net> skrev: > > > On 3/27/2022 5:23 PM, nop head wrote: > > function sector(radius, angles, fn = 24) = > let( > r = radius / cos(180 / fn), > step = -360 / fn, > points = concat([[0, 0]], > [for(a = [angles[0] : step : angles[1] - 360]) > [r * cos(a), r * sin(a)] > ], > [[r * cos(angles[1]), r * sin(angles[1])]] > ) > ) points; > > radius = 10; > angles = [0, 90]; > > echo(sector(radius, angles)); > > > Simplifying a little - the concat isn't necessary; you can just directly > create the list: > > function sector(radius, angles, fn = 24) = > let( > r = radius / cos(180 / fn), > step = -360 / fn, > points = [ > [0, 0], > for(a = [angles[0] : step : angles[1] - 360]) > [r * cos(a), r * sin(a)], > [r * cos(angles[1]), r * sin(angles[1])] > ] > ) points; > > radius = 10; > angles = [0, 90]; > > echo(sector(radius, angles)); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > ---------- Forwarded message ---------- > From: "Jan Öhman via Discuss" <discuss@lists.openscad.org> > To: OpenSCAD general discussion <discuss@lists.openscad.org> > Cc: "Jan Öhman" <jan_ohman@yahoo.com> > Bcc: > Date: Tue, 29 Mar 2022 10:00:25 +0000 (UTC) > Subject: [OpenSCAD] Re: Restrictions on functions and modules or .other > alternative > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >