discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Build a wall for a box - here is the profile

JB
Jordan Brown
Fri, Mar 25, 2022 12:26 AM

On 3/24/2022 4:56 PM, Jan Öhman via Discuss wrote:

Is it possible to combine the examples below

Anything is possible... it's just work.

I'm not a BOSL2 expert, but it looks like a start would be to replace
the "verts = pentagon(...)" with your own list of points, however you
might derive it.

If I understand it correctly, the base plate must be defined by a formula.

Must?  No.  Any of these schemes work with a list of points, and how you
come up with the list of points is up to you.

But is it possible to put together several formulas? (in some way)

  1. A formula from the first corner (90 degrees) to the second corner
  2. The second corner (a circle sector of 90 gtrader) should not be
    difficult.
  3. A line to the third corner.
  4. 3rd corner (circle sector <90 degrees)
  5. Where should the next straight line begin
    etc.

Sure.  You can use "concat" to concatenate several lists of points, or
you can use list comprehension syntax to build the list all at once.

Say we wanted a square with with the top-left and bottom-right corners
rounded.  Here's a solution with concat():

size = 20;
r = 3;
function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ];

points = concat(
    [[0,0]],
    arc([270:10:360], r, [size-r, r]),
    [[size, size]],
    arc([90:10:180], r, [r, size-r])
);
polygon(points);

and an equivalent solution using the "each" list comprehension:

size = 20;
r = 3;
function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ];

points = [
    [0,0],
    each arc([270:10:360], r, [size-r, r]),
    [size, size],
    each arc([90:10:180], r, [r, size-r])
];
polygon(points);

and of course both of those are using a list comprehension in arc() to
generate the points for an arc.

The arc formulas could have been embedded directly in the list (but
losing the clarity of having a named function):

size = 20;
r = 3;

points = [
    [0,0],
    for (a = [270:10:360]) r*[cos(a), sin(a)] + [size-r, r],
    [size, size],
    for (a = [90:10:180]) r*[cos(a), sin(a)] + [r, size-r],
];
polygon(points);
On 3/24/2022 4:56 PM, Jan Öhman via Discuss wrote: > Is it possible to combine the examples below Anything is possible... it's just work. I'm not a BOSL2 expert, but it looks like a start would be to replace the "verts = pentagon(...)" with your own list of points, however you might derive it. > If I understand it correctly, the base plate must be defined by a formula. Must?  No.  Any of these schemes work with a list of points, and how you come up with the list of points is up to you. > But is it possible to put together several formulas? (in some way) > 1) A formula from the first corner (90 degrees) to the second corner > 2) The second corner (a circle sector of 90 gtrader) should not be > difficult. > 3) A line to the third corner. > 4) 3rd corner (circle sector <90 degrees) > 5) Where should the next straight line begin > etc. Sure.  You can use "concat" to concatenate several lists of points, or you can use list comprehension syntax to build the list all at once. Say we wanted a square with with the top-left and bottom-right corners rounded.  Here's a solution with concat(): size = 20; r = 3; function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ]; points = concat( [[0,0]], arc([270:10:360], r, [size-r, r]), [[size, size]], arc([90:10:180], r, [r, size-r]) ); polygon(points); and an equivalent solution using the "each" list comprehension: size = 20; r = 3; function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ]; points = [ [0,0], each arc([270:10:360], r, [size-r, r]), [size, size], each arc([90:10:180], r, [r, size-r]) ]; polygon(points); and of course both of those are using a list comprehension in arc() to generate the points for an arc. The arc formulas could have been embedded directly in the list (but losing the clarity of having a named function): size = 20; r = 3; points = [ [0,0], for (a = [270:10:360]) r*[cos(a), sin(a)] + [size-r, r], [size, size], for (a = [90:10:180]) r*[cos(a), sin(a)] + [r, size-r], ]; polygon(points);
FH
Father Horton
Fri, Mar 25, 2022 12:33 AM

BOSL2's turtle functionality can be a good way to do this.
https://github.com/revarbat/BOSL2/wiki/drawing.scad#function-turtle

On Thu, Mar 24, 2022 at 7:26 PM Jordan Brown openscad@jordan.maileater.net
wrote:

On 3/24/2022 4:56 PM, Jan Öhman via Discuss wrote:

Is it possible to combine the examples below

Anything is possible... it's just work.

I'm not a BOSL2 expert, but it looks like a start would be to replace the
"verts = pentagon(...)" with your own list of points, however you might
derive it.

If I understand it correctly, the base plate must be defined by a formula.

Must?  No.  Any of these schemes work with a list of points, and how you
come up with the list of points is up to you.

But is it possible to put together several formulas? (in some way)

  1. A formula from the first corner (90 degrees) to the second corner
  2. The second corner (a circle sector of 90 gtrader) should not be
    difficult.
  3. A line to the third corner.
  4. 3rd corner (circle sector <90 degrees)
  5. Where should the next straight line begin
    etc.

Sure.  You can use "concat" to concatenate several lists of points, or you
can use list comprehension syntax to build the list all at once.

Say we wanted a square with with the top-left and bottom-right corners
rounded.  Here's a solution with concat():

size = 20;
r = 3;
function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ];

points = concat(
[[0,0]],
arc([270:10:360], r, [size-r, r]),
[[size, size]],
arc([90:10:180], r, [r, size-r])
);
polygon(points);

and an equivalent solution using the "each" list comprehension:

size = 20;
r = 3;
function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ];

points = [
[0,0],
each arc([270:10:360], r, [size-r, r]),
[size, size],
each arc([90:10:180], r, [r, size-r])
];
polygon(points);

and of course both of those are using a list comprehension in arc() to
generate the points for an arc.

The arc formulas could have been embedded directly in the list (but losing
the clarity of having a named function):

size = 20;
r = 3;

points = [
[0,0],
for (a = [270:10:360]) r*[cos(a), sin(a)] + [size-r, r],
[size, size],
for (a = [90:10:180]) r*[cos(a), sin(a)] + [r, size-r],
];
polygon(points);


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

BOSL2's turtle functionality can be a good way to do this. https://github.com/revarbat/BOSL2/wiki/drawing.scad#function-turtle On Thu, Mar 24, 2022 at 7:26 PM Jordan Brown <openscad@jordan.maileater.net> wrote: > On 3/24/2022 4:56 PM, Jan Öhman via Discuss wrote: > > Is it possible to combine the examples below > > > Anything is possible... it's just work. > > I'm not a BOSL2 expert, but it looks like a start would be to replace the > "verts = pentagon(...)" with your own list of points, however you might > derive it. > > If I understand it correctly, the base plate must be defined by a formula. > > > Must? No. Any of these schemes work with a list of points, and how you > come up with the list of points is up to you. > > But is it possible to put together several formulas? (in some way) > 1) A formula from the first corner (90 degrees) to the second corner > 2) The second corner (a circle sector of 90 gtrader) should not be > difficult. > 3) A line to the third corner. > 4) 3rd corner (circle sector <90 degrees) > 5) Where should the next straight line begin > etc. > > > Sure. You can use "concat" to concatenate several lists of points, or you > can use list comprehension syntax to build the list all at once. > > Say we wanted a square with with the top-left and bottom-right corners > rounded. Here's a solution with concat(): > > size = 20; > r = 3; > function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ]; > > points = concat( > [[0,0]], > arc([270:10:360], r, [size-r, r]), > [[size, size]], > arc([90:10:180], r, [r, size-r]) > ); > polygon(points); > > and an equivalent solution using the "each" list comprehension: > > size = 20; > r = 3; > function arc(range, r, origin) = [ for (a = range) r*[cos(a), sin(a)] + origin ]; > > points = [ > [0,0], > each arc([270:10:360], r, [size-r, r]), > [size, size], > each arc([90:10:180], r, [r, size-r]) > ]; > polygon(points); > > and of course both of those are using a list comprehension in arc() to > generate the points for an arc. > > The arc formulas could have been embedded directly in the list (but losing > the clarity of having a named function): > > size = 20; > r = 3; > > points = [ > [0,0], > for (a = [270:10:360]) r*[cos(a), sin(a)] + [size-r, r], > [size, size], > for (a = [90:10:180]) r*[cos(a), sin(a)] + [r, size-r], > ]; > polygon(points); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >