AM
Adrian Mariano
Thu, Mar 30, 2023 3:19 AM
If it's supposed to be a perfect V then something like this:
include<BOSL2/std.scad>
module thing(){
path = round_corners(zrot(45, rect(40)), radius=5,closed=true);
path_sweep(rect([5,1]),path,closed=true);
}
right_half()yrot(-20)thing();
left_half()yrot(20)thing();
There was a post maybe a year ago about folding where someone wanted to
perform a sequence of folds. It is a simpler thing than doing a path
sweep. I do think that path sweep can make the shape you show, but you
have to control the normals and twist properly, which will be tricky to
do. That is the general problem with path_sweep: it's not a well-defined
operation.
[image: image.png]
Now that I think about it, the starting shape should have been simply a
difference of two rounded rectangles. Or a tube. But this works for a
large class of objects.
On Wed, Mar 29, 2023 at 10:30 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:
This is close but not exactly what I wanted to do.
You can check my file and if you look from x+ direction, it is a perfect
'V'.
Path extrude function of Guenther and you seems to be quite similar.
On Thu, 30 Mar, 2023, 1:56 am Adrian Mariano, avm4@cornell.edu wrote:
I'm confused. This seems to be a simple application of a path sweep
operation, though it would be better to figure out the angle in an
automated way.
include<BOSL2/std.scad>
include<BOSL2/rounding.scad>
p = [[20,0,10],[0,20,0],[-20,0,10],[0,-20,0]];
pround = round_corners(p,radius=5,closed=true);
profile = zrot(-20,rect([5,1]));
path_sweep(profile,pround,closed=true);
[image: image.png]
On Wed, Mar 29, 2023 at 11:43 AM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:
I have written the code which does this, but not with path_extrude,
which I tried initially.
This is a kind of folding or bending of a sheet, so this is not simple
to do in openscad
On Wed, 29 Mar 2023 at 17:08, Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:
I don't think there is any path extrude in openscad.
Few developers have written this function.
The version I wrote could not handle this kind of problem.
On Wed, 29 Mar, 2023, 4:50 pm Adrian Mariano, avm4@cornell.edu wrote:
Is there a path_extrude() in some version of OpenSCAD?
On Wed, Mar 29, 2023 at 2:33 AM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:
If you look from -y direction, it should look like a 'V' shape
On Wed, 29 Mar, 2023, 11:52 am Guenther Sohler, <
guenther.sohler@gmail.com> wrote:
section should be a rectangle 5 x 1 with vertices
[[0,0],[5,0],[5,1],[0,1]]
path is mainly a list of 4 vertices with a radius of 5 at each point
[[20,0,10],[0,20,0],[-20,0,10],[0,-20,0]]
I dont have my computer with me right now, but this is what it
should be
On Wed, 29 Mar 2023, 08:56 Adrian Mariano, avm4@cornell.edu
wrote:
It seems like it should be possible. Supply the point list and
profile and I can try it. What problem do you have?
On Tue, Mar 28, 2023 at 10:49 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:
Can this be achieved through path_extrude?
I have tried various ways but could not achieve it.
[image: Screenshot 2023-03-28 at 9.12.31 PM.png]
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If it's supposed to be a perfect V then something like this:
include<BOSL2/std.scad>
module thing(){
path = round_corners(zrot(45, rect(40)), radius=5,closed=true);
path_sweep(rect([5,1]),path,closed=true);
}
right_half()yrot(-20)thing();
left_half()yrot(20)thing();
There was a post maybe a year ago about folding where someone wanted to
perform a sequence of folds. It is a simpler thing than doing a path
sweep. I do think that path sweep can make the shape you show, but you
have to control the normals and twist properly, which will be tricky to
do. That is the general problem with path_sweep: it's not a well-defined
operation.
[image: image.png]
Now that I think about it, the starting shape should have been simply a
difference of two rounded rectangles. Or a tube. But this works for a
large class of objects.
On Wed, Mar 29, 2023 at 10:30 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com>
wrote:
> This is close but not exactly what I wanted to do.
>
> You can check my file and if you look from x+ direction, it is a perfect
> 'V'.
>
> Path extrude function of Guenther and you seems to be quite similar.
>
>
>
>
> On Thu, 30 Mar, 2023, 1:56 am Adrian Mariano, <avm4@cornell.edu> wrote:
>
>> I'm confused. This seems to be a simple application of a path sweep
>> operation, though it would be better to figure out the angle in an
>> automated way.
>>
>> include<BOSL2/std.scad>
>> include<BOSL2/rounding.scad>
>>
>> p = [[20,0,10],[0,20,0],[-20,0,10],[0,-20,0]];
>> pround = round_corners(p,radius=5,closed=true);
>> profile = zrot(-20,rect([5,1]));
>>
>> path_sweep(profile,pround,closed=true);
>>
>>
>> [image: image.png]
>>
>>
>> On Wed, Mar 29, 2023 at 11:43 AM Sanjeev Prabhakar <
>> sprabhakar2006@gmail.com> wrote:
>>
>>> I have written the code which does this, but not with path_extrude,
>>> which I tried initially.
>>> This is a kind of folding or bending of a sheet, so this is not simple
>>> to do in openscad
>>>
>>> On Wed, 29 Mar 2023 at 17:08, Sanjeev Prabhakar <
>>> sprabhakar2006@gmail.com> wrote:
>>>
>>>> I don't think there is any path extrude in openscad.
>>>> Few developers have written this function.
>>>> The version I wrote could not handle this kind of problem.
>>>>
>>>>
>>>>
>>>> On Wed, 29 Mar, 2023, 4:50 pm Adrian Mariano, <avm4@cornell.edu> wrote:
>>>>
>>>>> Is there a path_extrude() in some version of OpenSCAD?
>>>>>
>>>>> On Wed, Mar 29, 2023 at 2:33 AM Sanjeev Prabhakar <
>>>>> sprabhakar2006@gmail.com> wrote:
>>>>>
>>>>>> If you look from -y direction, it should look like a 'V' shape
>>>>>>
>>>>>> On Wed, 29 Mar, 2023, 11:52 am Guenther Sohler, <
>>>>>> guenther.sohler@gmail.com> wrote:
>>>>>>
>>>>>>> Hi Sanjeev,
>>>>>>>
>>>>>>> is this what you are looking for?
>>>>>>>
>>>>>>> [image: image.png]
>>>>>>>
>>>>>>> just angle of 60 deg was guessed
>>>>>>>
>>>>>>> https://imgpile.com/i/hxk8PC
>>>>>>>
>>>>>>> On Wed, Mar 29, 2023 at 6:39 AM Sanjeev Prabhakar <
>>>>>>> sprabhakar2006@gmail.com> wrote:
>>>>>>>
>>>>>>>> section should be a rectangle 5 x 1 with vertices
>>>>>>>> [[0,0],[5,0],[5,1],[0,1]]
>>>>>>>>
>>>>>>>> path is mainly a list of 4 vertices with a radius of 5 at each point
>>>>>>>>
>>>>>>>> [[20,0,10],[0,20,0],[-20,0,10],[0,-20,0]]
>>>>>>>>
>>>>>>>> I dont have my computer with me right now, but this is what it
>>>>>>>> should be
>>>>>>>>
>>>>>>>> On Wed, 29 Mar 2023, 08:56 Adrian Mariano, <avm4@cornell.edu>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> It seems like it should be possible. Supply the point list and
>>>>>>>>> profile and I can try it. What problem do you have?
>>>>>>>>>
>>>>>>>>> On Tue, Mar 28, 2023 at 10:49 PM Sanjeev Prabhakar <
>>>>>>>>> sprabhakar2006@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Can this be achieved through path_extrude?
>>>>>>>>>>
>>>>>>>>>> I have tried various ways but could not achieve it.
>>>>>>>>>>
>>>>>>>>>> [image: Screenshot 2023-03-28 at 9.12.31 PM.png]
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> 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
>>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>> _______________________________________________
>>> 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
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
SP
Sanjeev Prabhakar
Thu, Mar 30, 2023 4:03 AM
below is the expected figure
[image: Screenshot 2023-03-30 at 9.30.08 AM.png]
[image: Screenshot 2023-03-30 at 9.32.55 AM.png]
below is the expected figure
[image: Screenshot 2023-03-30 at 9.30.08 AM.png]
[image: Screenshot 2023-03-30 at 9.32.55 AM.png]
>
>
GS
Guenther Sohler
Thu, Mar 30, 2023 9:16 AM
its great!
can you explain us the exact application ? is it a sealing ?
On Thu, Mar 30, 2023 at 6:05 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:
below is the expected figure
[image: Screenshot 2023-03-30 at 9.30.08 AM.png]
[image: Screenshot 2023-03-30 at 9.32.55 AM.png]
its great!
can you explain us the exact application ? is it a sealing ?
On Thu, Mar 30, 2023 at 6:05 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com>
wrote:
> below is the expected figure
> [image: Screenshot 2023-03-30 at 9.30.08 AM.png]
>
> [image: Screenshot 2023-03-30 at 9.32.55 AM.png]
>>
>> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
SP
Sanjeev Prabhakar
Thu, Mar 30, 2023 10:50 AM
No application just an arbitrary shape.
There are a lot of application for sheet bending to different shapes and
sizes.
This is probably a very simplistic example.
On Thu, 30 Mar, 2023, 2:46 pm Guenther Sohler, guenther.sohler@gmail.com
wrote:
its great!
can you explain us the exact application ? is it a sealing ?
On Thu, Mar 30, 2023 at 6:05 AM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:
below is the expected figure
[image: Screenshot 2023-03-30 at 9.30.08 AM.png]
[image: Screenshot 2023-03-30 at 9.32.55 AM.png]
No application just an arbitrary shape.
There are a lot of application for sheet bending to different shapes and
sizes.
This is probably a very simplistic example.
On Thu, 30 Mar, 2023, 2:46 pm Guenther Sohler, <guenther.sohler@gmail.com>
wrote:
> its great!
>
> can you explain us the exact application ? is it a sealing ?
>
> On Thu, Mar 30, 2023 at 6:05 AM Sanjeev Prabhakar <
> sprabhakar2006@gmail.com> wrote:
>
>> below is the expected figure
>> [image: Screenshot 2023-03-30 at 9.30.08 AM.png]
>>
>> [image: Screenshot 2023-03-30 at 9.32.55 AM.png]
>>>
>>> _______________________________________________
>> 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
>
CA
Carsten Arnholm
Thu, Mar 30, 2023 4:46 PM
On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
There are a lot of application for sheet bending to different shapes
and sizes.
This is probably a very simplistic example.
This model is most easily made by extruding a 2d profile with a
relatively dense mesh in the bend area. Then bend the model by rotating
nodes around y=constant. You can't do the last part in OpenSCAD though.
Carsten Arnholm
On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
> There are a lot of application for sheet bending to different shapes
> and sizes.
> This is probably a very simplistic example.
This model is most easily made by extruding a 2d profile with a
relatively dense mesh in the bend area. Then bend the model by rotating
nodes around y=constant. You can't do the last part in OpenSCAD though.
Carsten Arnholm
GS
Guenther Sohler
Thu, Mar 30, 2023 4:50 PM
hi Carsten,
can you please elaborate, what it exactly means:
rotating while y=contant. ?
I doubt you refer to rotation in X-Z plane ...
On Thu, Mar 30, 2023 at 6:47 PM Carsten Arnholm arnholm@arnholm.org wrote:
On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
There are a lot of application for sheet bending to different shapes
and sizes.
This is probably a very simplistic example.
This model is most easily made by extruding a 2d profile with a
relatively dense mesh in the bend area. Then bend the model by rotating
nodes around y=constant. You can't do the last part in OpenSCAD though.
Carsten Arnholm
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
hi Carsten,
can you please elaborate, what it exactly means:
rotating while y=contant. ?
I doubt you refer to rotation in X-Z plane ...
On Thu, Mar 30, 2023 at 6:47 PM Carsten Arnholm <arnholm@arnholm.org> wrote:
> On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
> > There are a lot of application for sheet bending to different shapes
> > and sizes.
> > This is probably a very simplistic example.
>
> This model is most easily made by extruding a 2d profile with a
> relatively dense mesh in the bend area. Then bend the model by rotating
> nodes around y=constant. You can't do the last part in OpenSCAD though.
>
> Carsten Arnholm
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
CA
Carsten Arnholm
Thu, Mar 30, 2023 5:55 PM
On 30.03.2023 18:50, Guenther Sohler wrote:
can you please elaborate, what it exactly means:
rotating while y=contant. ?
I doubt you refer to rotation in X-Z plane ...
I said rotate "around y=constant". That means in this case a rotation
axis parallel to the X axis. Obviously it is not a solid body rotation,
but a rotation of individual mesh nodes resulting in bending the model
when represented as a mesh.
Carsten Anrholm
On 30.03.2023 18:50, Guenther Sohler wrote:
> can you please elaborate, what it exactly means:
> rotating while y=contant. ?
>
> I doubt you refer to rotation in X-Z plane ...
>
I said rotate "around y=constant". That means in this case a rotation
axis parallel to the X axis. Obviously it is not a solid body rotation,
but a rotation of individual mesh nodes resulting in bending the model
when represented as a mesh.
Carsten Anrholm
AM
Adrian Mariano
Thu, Mar 30, 2023 8:31 PM
Actually the approach Carsten describes is possible in openscad if you are
working with points and not geometry. In BOSL2 there is already vnf_bend()
which bends an arbitrary polyhedron around a cylinder.
https://github.com/revarbat/BOSL2/wiki/vnf.scad#function-vnf_bend
The task of "folding" with a rounded fold is very similar to this. The
vnf_bend() function slices up the polyhedron so that you have a sufficient
sample rate to produce the desired curves. I thought about trying to
implement the "folding" transform but it's tricky to write the function
that does the fold, so I'm probably not going to do it. But here's an
example using BOSL2 where I took vnf_bend and removed the "bend" part and
made it into a generalized distortion module that can then apply an
arbitrary function to distort the given shape. Supply the f() that
performs the bend that you want and you can bend shapes that you can build
as polyhedra that aren't too complicated. (It's probably a long wait it
you have thousands of faces.)
include<BOSL2/std.scad>
function vnf_distort(vnf,f,steps=10,axis="Z") =
let(
chk_axis = assert(in_list(axis,["X","Y","Z"])),
verts = vnf[0],
bounds = pointlist_bounds(verts),
bmin = bounds[0],
bmax = bounds[1],
dflt = axis=="Z"?
max(abs(bmax.y), abs(bmin.y)) :
max(abs(bmax.z), abs(bmin.z)),
extent = axis=="X" ? [bmin.y, bmax.y] : [bmin.x, bmax.x]
)
let(
//steps = 1+ceil(segs(r) * (extent[1]-extent[0])/(2PIr)),
step = (extent[1]-extent[0]) / steps,
bend_at = [for(i = [1:1:steps-1]) i*step+extent[0]],
slicedir = axis=="X"? "Y" : "X", // slice in y dir for X axis
case, and x dir otherwise
sliced = vnf_slice(vnf, slicedir, bend_at),
new_vert = [for(p=sliced[0]) f(p)]
) [new_vert,sliced[1]];
f = function(p)
[p.x, p.y, 7sin(4p.x)+p.z+45];
rgn = union(
rect([20,100]),
back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
);
rgnr = zrot(90, p=rgn);
vnf0 = xrot(90,p=linear_sweep(rgnr, height=10));
vnf1 = fwd(50, p=vnf0);
vnf_polyhedron(vnf1);
bent1 = vnf_distort(vnf1,f,steps=32);
vnf_polyhedron(bent1);
Which produces the distorted wiggly arrow at the top from the straight
arrow at the bottom:
[image: image.png]
On Thu, Mar 30, 2023 at 1:56 PM Carsten Arnholm arnholm@arnholm.org wrote:
On 30.03.2023 18:50, Guenther Sohler wrote:
can you please elaborate, what it exactly means:
rotating while y=contant. ?
I doubt you refer to rotation in X-Z plane ...
I said rotate "around y=constant". That means in this case a rotation
axis parallel to the X axis. Obviously it is not a solid body rotation,
but a rotation of individual mesh nodes resulting in bending the model
when represented as a mesh.
Carsten Anrholm
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Actually the approach Carsten describes is possible in openscad if you are
working with points and not geometry. In BOSL2 there is already vnf_bend()
which bends an arbitrary polyhedron around a cylinder.
https://github.com/revarbat/BOSL2/wiki/vnf.scad#function-vnf_bend
The task of "folding" with a rounded fold is very similar to this. The
vnf_bend() function slices up the polyhedron so that you have a sufficient
sample rate to produce the desired curves. I thought about trying to
implement the "folding" transform but it's tricky to write the function
that does the fold, so I'm probably not going to do it. But here's an
example using BOSL2 where I took vnf_bend and removed the "bend" part and
made it into a generalized distortion module that can then apply an
arbitrary function to distort the given shape. Supply the f() that
performs the bend that you want and you can bend shapes that you can build
as polyhedra that aren't too complicated. (It's probably a long wait it
you have thousands of faces.)
include<BOSL2/std.scad>
function vnf_distort(vnf,f,steps=10,axis="Z") =
let(
chk_axis = assert(in_list(axis,["X","Y","Z"])),
verts = vnf[0],
bounds = pointlist_bounds(verts),
bmin = bounds[0],
bmax = bounds[1],
dflt = axis=="Z"?
max(abs(bmax.y), abs(bmin.y)) :
max(abs(bmax.z), abs(bmin.z)),
extent = axis=="X" ? [bmin.y, bmax.y] : [bmin.x, bmax.x]
)
let(
//steps = 1+ceil(segs(r) * (extent[1]-extent[0])/(2*PI*r)),
step = (extent[1]-extent[0]) / steps,
bend_at = [for(i = [1:1:steps-1]) i*step+extent[0]],
slicedir = axis=="X"? "Y" : "X", // slice in y dir for X axis
case, and x dir otherwise
sliced = vnf_slice(vnf, slicedir, bend_at),
new_vert = [for(p=sliced[0]) f(p)]
) [new_vert,sliced[1]];
f = function(p)
[p.x, p.y, 7*sin(4*p.x)+p.z+45];
rgn = union(
rect([20,100]),
back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
);
rgnr = zrot(90, p=rgn);
vnf0 = xrot(90,p=linear_sweep(rgnr, height=10));
vnf1 = fwd(50, p=vnf0);
vnf_polyhedron(vnf1);
bent1 = vnf_distort(vnf1,f,steps=32);
vnf_polyhedron(bent1);
Which produces the distorted wiggly arrow at the top from the straight
arrow at the bottom:
[image: image.png]
On Thu, Mar 30, 2023 at 1:56 PM Carsten Arnholm <arnholm@arnholm.org> wrote:
> On 30.03.2023 18:50, Guenther Sohler wrote:
> > can you please elaborate, what it exactly means:
> > rotating while y=contant. ?
> >
> > I doubt you refer to rotation in X-Z plane ...
> >
> I said rotate "around y=constant". That means in this case a rotation
> axis parallel to the X axis. Obviously it is not a solid body rotation,
> but a rotation of individual mesh nodes resulting in bending the model
> when represented as a mesh.
>
> Carsten Anrholm
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
SP
Sanjeev Prabhakar
Fri, Mar 31, 2023 1:06 AM
Thanks,
I have written something similar.
You don't need a dense mesh in this case, though in many cases it may be
required.
I have a very simplistic function for path_extrude, initially I thought
this could be done with path_extrude, but I realised later this may not
be possible by extruding a 2d shape.
On Thu, 30 Mar, 2023, 10:16 pm Carsten Arnholm, arnholm@arnholm.org wrote:
On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
There are a lot of application for sheet bending to different shapes
and sizes.
This is probably a very simplistic example.
This model is most easily made by extruding a 2d profile with a
relatively dense mesh in the bend area. Then bend the model by rotating
nodes around y=constant. You can't do the last part in OpenSCAD though.
Carsten Arnholm
Thanks,
I have written something similar.
You don't need a dense mesh in this case, though in many cases it may be
required.
I have a very simplistic function for path_extrude, initially I thought
this could be done with path_extrude, but I realised later this may not
be possible by extruding a 2d shape.
On Thu, 30 Mar, 2023, 10:16 pm Carsten Arnholm, <arnholm@arnholm.org> wrote:
> On 2023-03-30 12:50, Sanjeev Prabhakar wrote:
> > There are a lot of application for sheet bending to different shapes
> > and sizes.
> > This is probably a very simplistic example.
>
> This model is most easily made by extruding a 2d profile with a
> relatively dense mesh in the bend area. Then bend the model by rotating
> nodes around y=constant. You can't do the last part in OpenSCAD though.
>
> Carsten Arnholm
>
SP
Sanjeev Prabhakar
Fri, Mar 31, 2023 1:12 AM
Looks great
Normally I bend a 2d shape first and then create a surface from that
through offset.
On Fri, 31 Mar, 2023, 2:02 am Adrian Mariano, avm4@cornell.edu wrote:
Actually the approach Carsten describes is possible in openscad if you are
working with points and not geometry. In BOSL2 there is already vnf_bend()
which bends an arbitrary polyhedron around a cylinder.
https://github.com/revarbat/BOSL2/wiki/vnf.scad#function-vnf_bend
The task of "folding" with a rounded fold is very similar to this. The
vnf_bend() function slices up the polyhedron so that you have a sufficient
sample rate to produce the desired curves. I thought about trying to
implement the "folding" transform but it's tricky to write the function
that does the fold, so I'm probably not going to do it. But here's an
example using BOSL2 where I took vnf_bend and removed the "bend" part and
made it into a generalized distortion module that can then apply an
arbitrary function to distort the given shape. Supply the f() that
performs the bend that you want and you can bend shapes that you can build
as polyhedra that aren't too complicated. (It's probably a long wait it
you have thousands of faces.)
include<BOSL2/std.scad>
function vnf_distort(vnf,f,steps=10,axis="Z") =
let(
chk_axis = assert(in_list(axis,["X","Y","Z"])),
verts = vnf[0],
bounds = pointlist_bounds(verts),
bmin = bounds[0],
bmax = bounds[1],
dflt = axis=="Z"?
max(abs(bmax.y), abs(bmin.y)) :
max(abs(bmax.z), abs(bmin.z)),
extent = axis=="X" ? [bmin.y, bmax.y] : [bmin.x, bmax.x]
)
let(
//steps = 1+ceil(segs(r) * (extent[1]-extent[0])/(2PIr)),
step = (extent[1]-extent[0]) / steps,
bend_at = [for(i = [1:1:steps-1]) i*step+extent[0]],
slicedir = axis=="X"? "Y" : "X", // slice in y dir for X axis
case, and x dir otherwise
sliced = vnf_slice(vnf, slicedir, bend_at),
new_vert = [for(p=sliced[0]) f(p)]
) [new_vert,sliced[1]];
f = function(p)
[p.x, p.y, 7sin(4p.x)+p.z+45];
rgn = union(
rect([20,100]),
back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
);
rgnr = zrot(90, p=rgn);
vnf0 = xrot(90,p=linear_sweep(rgnr, height=10));
vnf1 = fwd(50, p=vnf0);
vnf_polyhedron(vnf1);
bent1 = vnf_distort(vnf1,f,steps=32);
vnf_polyhedron(bent1);
Which produces the distorted wiggly arrow at the top from the straight
arrow at the bottom:
[image: image.png]
On Thu, Mar 30, 2023 at 1:56 PM Carsten Arnholm arnholm@arnholm.org
wrote:
On 30.03.2023 18:50, Guenther Sohler wrote:
can you please elaborate, what it exactly means:
rotating while y=contant. ?
I doubt you refer to rotation in X-Z plane ...
I said rotate "around y=constant". That means in this case a rotation
axis parallel to the X axis. Obviously it is not a solid body rotation,
but a rotation of individual mesh nodes resulting in bending the model
when represented as a mesh.
Carsten Anrholm
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Looks great
Normally I bend a 2d shape first and then create a surface from that
through offset.
On Fri, 31 Mar, 2023, 2:02 am Adrian Mariano, <avm4@cornell.edu> wrote:
> Actually the approach Carsten describes is possible in openscad if you are
> working with points and not geometry. In BOSL2 there is already vnf_bend()
> which bends an arbitrary polyhedron around a cylinder.
>
> https://github.com/revarbat/BOSL2/wiki/vnf.scad#function-vnf_bend
>
> The task of "folding" with a rounded fold is very similar to this. The
> vnf_bend() function slices up the polyhedron so that you have a sufficient
> sample rate to produce the desired curves. I thought about trying to
> implement the "folding" transform but it's tricky to write the function
> that does the fold, so I'm probably not going to do it. But here's an
> example using BOSL2 where I took vnf_bend and removed the "bend" part and
> made it into a generalized distortion module that can then apply an
> arbitrary function to distort the given shape. Supply the f() that
> performs the bend that you want and you can bend shapes that you can build
> as polyhedra that aren't too complicated. (It's probably a long wait it
> you have thousands of faces.)
>
> include<BOSL2/std.scad>
>
> function vnf_distort(vnf,f,steps=10,axis="Z") =
> let(
> chk_axis = assert(in_list(axis,["X","Y","Z"])),
> verts = vnf[0],
> bounds = pointlist_bounds(verts),
> bmin = bounds[0],
> bmax = bounds[1],
> dflt = axis=="Z"?
> max(abs(bmax.y), abs(bmin.y)) :
> max(abs(bmax.z), abs(bmin.z)),
> extent = axis=="X" ? [bmin.y, bmax.y] : [bmin.x, bmax.x]
> )
> let(
> //steps = 1+ceil(segs(r) * (extent[1]-extent[0])/(2*PI*r)),
> step = (extent[1]-extent[0]) / steps,
> bend_at = [for(i = [1:1:steps-1]) i*step+extent[0]],
> slicedir = axis=="X"? "Y" : "X", // slice in y dir for X axis
> case, and x dir otherwise
> sliced = vnf_slice(vnf, slicedir, bend_at),
> new_vert = [for(p=sliced[0]) f(p)]
> ) [new_vert,sliced[1]];
>
>
> f = function(p)
> [p.x, p.y, 7*sin(4*p.x)+p.z+45];
>
>
> rgn = union(
> rect([20,100]),
> back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
> );
> rgnr = zrot(90, p=rgn);
> vnf0 = xrot(90,p=linear_sweep(rgnr, height=10));
> vnf1 = fwd(50, p=vnf0);
> vnf_polyhedron(vnf1);
> bent1 = vnf_distort(vnf1,f,steps=32);
> vnf_polyhedron(bent1);
>
>
> Which produces the distorted wiggly arrow at the top from the straight
> arrow at the bottom:
>
> [image: image.png]
>
>
> On Thu, Mar 30, 2023 at 1:56 PM Carsten Arnholm <arnholm@arnholm.org>
> wrote:
>
>> On 30.03.2023 18:50, Guenther Sohler wrote:
>> > can you please elaborate, what it exactly means:
>> > rotating while y=contant. ?
>> >
>> > I doubt you refer to rotation in X-Z plane ...
>> >
>> I said rotate "around y=constant". That means in this case a rotation
>> axis parallel to the X axis. Obviously it is not a solid body rotation,
>> but a rotation of individual mesh nodes resulting in bending the model
>> when represented as a mesh.
>>
>> Carsten Anrholm
>> _______________________________________________
>> 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
>