bending a shape that's only slightly complex

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

bending a shape that's only slightly complex

khackbarth

Is there a way to make this simple shape bend into a circle? … and keep the render time under an hour… 😊

 

$fn=40;

radius=.5;

offset=radius*2;

 

    for(i=[0:5]){

        sign=(i%2==0) ? 1 : -1;

       

        translate([offset*2*i,0,0])

        rotate_extrude(angle=sign*180)

        translate([offset,0])

        circle(r=radius);

    }


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bending a shape that's only slightly complex

OpenSCAD mailing list-2
Is the circle in the x/y plane or the x/z plane?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bending a shape that's only slightly complex

nophead
I would generate the path as a list of points and then sweep a circle along the path. It would render almost instantly.

On Wed, 9 Dec 2020 at 15:43, fred_dot_u via Discuss <[hidden email]> wrote:
Is the circle in the x/y plane or the x/z plane?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

FW: bending a shape that's only slightly complex

khackbarth

Any chance you could provide a simple example?  I’ve never swept anything along a path…

 

From: nop head <[hidden email]>
Sent: Wednesday, December 9, 2020 8:47 AM
To: OpenSCAD general discussion <[hidden email]>
Subject: Re: [OpenSCAD] bending a shape that's only slightly complex

 

I would generate the path as a list of points and then sweep a circle along the path. It would render almost instantly.

 

On Wed, 9 Dec 2020 at 15:43, fred_dot_u via Discuss <[hidden email]> wrote:

Is the circle in the x/y plane or the x/z plane?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

Ronaldo
Here is a possible code. The module path_sweep() is part of BOSL2 and sweep() is the classical one.

$fn=40;
radius=.5;
offset=radius*2;

    *for(i=[0:5]){
        sign=(i%2==0) ? 1 : -1;
        translate([offset*2*i,0,0])
        rotate_extrude(angle=sign*180)
        translate([offset,0])
        circle(r=radius);
    }

path = [for(i=[0:5],s=(i%2==0)? 1 : -1, a=[0:360/$fn:180-360/$fn])
           offset*[2*i-cos(s*a), sin(s*a),0] ];

function bend_xz(p) =
  let( perim = abs(p[len(p)-1].x-p[0].x),
       r = perim/PI/2 )
  [for(pi=p) [r*cos(360*pi.x/perim), pi.y,r*sin(360*pi.x/perim)] ];

//path_sweep(circle(radius),bend_xz(path),closed=true);
sweep(circle(radius),bend_xz(path),closed=true);

bend.PNG

Em qua., 9 de dez. de 2020 às 20:32, <[hidden email]> escreveu:

Any chance you could provide a simple example?  I’ve never swept anything along a path…

 

From: nop head <[hidden email]>
Sent: Wednesday, December 9, 2020 8:47 AM
To: OpenSCAD general discussion <[hidden email]>
Subject: Re: [OpenSCAD] bending a shape that's only slightly complex

 

I would generate the path as a list of points and then sweep a circle along the path. It would render almost instantly.

 

On Wed, 9 Dec 2020 at 15:43, fred_dot_u via Discuss <[hidden email]> wrote:

Is the circle in the x/y plane or the x/z plane?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bending a shape that's only slightly complex

lar3ry
This post was updated on .
In reply to this post by khackbarth
khackbarth wrote
> Is there a way to make this simple shape bend into a circle? … and keep
> the render time under an hour… 😊

Since you haven't responded to the question of which plane you want the
circle on, and you have not responded to the suggestions,   here's my take on it.

$fn=40;
radius=.5;
offset=radius*2;
 
rotate_extrude() {
        translate ([10,10,0])
                projection()
                        for(i=[0:5]){
                                sign=(i%2==0) ? 1 : -1;
                                translate([offset*2*i,0,0])
                                rotate_extrude(angle=sign*180)
                                translate([offset,0])
                                circle(r=radius);
                        }
                }


 Untitled.png
<http://forum.openscad.org/file/t2121/Untitled.png>


--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bending a shape that's only slightly complex

OpenSCAD mailing list-2
I received a reply, which apparently didn't make it to the list/forum that
the objective is to circle the wagons in the x/y plane. My interpretation in
2D is the image above. If I knew how to make it in 3D, I'd stuff the code in
here.

If the OP thinks my interpretation is incorrect, I hope it will be
corrected.

I'm looking forward to the solution.

<http://forum.openscad.org/file/t824/squiggle.png>



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bending a shape that's only slightly complex

khackbarth
In reply to this post by lar3ry
Hi Larry,

I did reply but my email program inserted only the direct address to fred_dot_u.  I told him X/Y.

Thanks for your input.

Ken

-----Original Message-----
From: lar3ry <[hidden email]>
Sent: Thursday, December 10, 2020 9:26 AM
To: [hidden email]
Subject: Re: [OpenSCAD] bending a shape that's only slightly complex

khackbarth wrote
> Is there a way to make this simple shape bend into a circle? … and
> keep the render time under an hour… 😊

Since you haven't responded to the question of which plane you want the circle on, and you have not responded to the suggestions,  Untitled.png <http://forum.openscad.org/file/t2121/Untitled.png>  here's my take on it.

$fn=40;
radius=.5;
offset=radius*2;
 
rotate_extrude() {
        translate ([10,10,0])
                projection()
                        for(i=[0:5]){
                                sign=(i%2==0) ? 1 : -1;
                                translate([offset*2*i,0,0])
                                rotate_extrude(angle=sign*180)
                                translate([offset,0])
                                circle(r=radius);
                        }
                }





--
Sent from: http://forum.openscad.org/




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

crunchysteve
In reply to this post by Ronaldo
Running stock OpenSCAD version 2019.05 on Mac OS (Big Sur, M1, Rosetta2 Intel
emulation), there is no command sweep(), I get the error "WARNING: Ignoring
unknown module 'sweep', in file ./, line 22."

And what is BOSL2?

Yeah, 3 years using OpenSCAD, and I still call myself a newbie. Sorry.


Ronaldo wrote

> Here is a possible code. The module path_sweep() is part of BOSL2 and
> sweep() is the classical one.
>
> $fn=40;
> radius=.5;
> offset=radius*2;
>
>     *for(i=[0:5]){
>         sign=(i%2==0) ? 1 : -1;
>         translate([offset*2*i,0,0])
>         rotate_extrude(angle=sign*180)
>         translate([offset,0])
>         circle(r=radius);
>     }
>
> path = [for(i=[0:5],s=(i%2==0)? 1 : -1, a=[0:360/$fn:180-360/$fn])
>            offset*[2*i-cos(s*a), sin(s*a),0] ];
>
> function bend_xz(p) =
>   let( perim = abs(p[len(p)-1].x-p[0].x),
>        r = perim/PI/2 )
>   [for(pi=p) [r*cos(360*pi.x/perim), pi.y,r*sin(360*pi.x/perim)] ];
>
> //path_sweep(circle(radius),bend_xz(path),closed=true);
> sweep(circle(radius),bend_xz(path),closed=true);
>
>
> [image: bend.PNG]
>
> Em qua., 9 de dez. de 2020 às 20:32, &lt;

> ken@

> &gt; escreveu:
>
>> Any chance you could provide a simple example?  I’ve never swept anything
>> along a path…
>>
>>
>>
>> *From:* nop head &lt;

> nop.head@

> &gt;
>> *Sent:* Wednesday, December 9, 2020 8:47 AM
>> *To:* OpenSCAD general discussion &lt;

> discuss@.openscad

> &gt;
>> *Subject:* Re: [OpenSCAD] bending a shape that's only slightly complex
>>
>>
>>
>> I would generate the path as a list of points and then sweep a circle
>> along the path. It would render almost instantly.
>>
>>
>>
>> On Wed, 9 Dec 2020 at 15:43, fred_dot_u via Discuss <
>>

> discuss@.openscad

>> wrote:
>>
>> Is the circle in the x/y plane or the x/z plane?
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> bend.PNG (29K)
> &lt;http://forum.openscad.org/attachment/31065/0/bend.PNG&gt;





-----
Make things, travel and tell stories.
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Make things, travel and tell stories.
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

crunchysteve
Answered "What is BOSL2?" for myself, disregard that question :D

Cheers



-----
Make things, travel and tell stories.
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Make things, travel and tell stories.
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

skypuppy
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

MichaelAtOz
Administrator
In reply to this post by crunchysteve
See  sweep <https://github.com/openscad/list-comprehension-demos>  .



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

adrianv
In reply to this post by skypuppy
Nobody posted an example of what I thought was desired:

include<BOSL2/std.scad>
include<BOSL2/skin.scad>

$fn=16;
ofs = 1;
r=4;
number=5;
radius=.4;     // If this is much bigger you need path_sweep2d

path = [for(i=[0:2:359]) (r+ofs*sin(number*i))*[cos(i),sin(i)]];
path_sweep(circle(r=radius), path, closed=true);
// path_sweep2d(circle(r=radius), path, closed=true);

Note that if you fiddle with the parameters you can get self-intersections
to occur at the peaks of the sin wave (creases in the model) and that makes
the model invalid.  (Curiously the RC version doesn't flag this as invalid,
even though the render is wrong!)  You can  handle the self-intersections
with path_sweep2d, but it's much slower, at least to preview, than the
regular path_sweep.  

BOSL2 is the Belfry OpenSCAD Library:  

https://github.com/revarbat/BOSL2/wiki

I believe the dotSCAD library also includes a path_sweep module (not sure
what it's called).   And of course list-comprehension-demos has the original
sweep().  


skypuppy wrote

> I'd like to know what it is before I jump down that rabbit hole.
>
> David
>
>
> On 12/10/20 8:18 PM, crunchysteve wrote:
>> Answered "What is BOSL2?" for myself, disregard that question :D
>>
>> Cheers
>>
>>
>>
>> -----
>> Make things, travel and tell stories.
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

adrianv
In reply to this post by MichaelAtOz
I think this version might be broken by the 2019.05 release.  It might
require a little hunting around on github for a working version, actually.  


MichaelAtOz wrote

> See  sweep &lt;https://github.com/openscad/list-comprehension-demos&gt;  .
>
>
>
> -----
> OpenSCAD Admin - email* me if you need anything,  or if I've done
> something stupid...
>
> * on the Forum, click on my MichaelAtOz label, there is a link to email
> me.
>
> Unless specifically shown otherwise above, my contribution is in the
> Public Domain; to the extent possible under law, I have waived all
> copyright and related or neighbouring rights to this work. Obviously
> inclusion of works of previous authors is not included in the above.
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

jon_bondy
In reply to this post by skypuppy
Wow.  BOSL has been talked about a LOT on this forum, and yet members do
not know about it.  That is surprising.

BOSL is a very full featured library

JOn

On 12/10/2020 10:04 PM, David wrote:

> I'd like to know what it is before I jump down that rabbit hole.
>
> David
>
>
> On 12/10/20 8:18 PM, crunchysteve wrote:
>> Answered "What is BOSL2?" for myself, disregard that question :D
>>
>> Cheers
>>
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: FW: bending a shape that's only slightly complex

thehans
In reply to this post by adrianv
I worked out the exact geometry of a path of circular arcs, and combined with sweep from BOSL2 in adrianv's example.

The arc function was copied from my FunctionalOpenSCAD library: https://github.com/thehans/FunctionalOpenSCAD (and renamed from "arc" to "my_arc" so it doesn't conflict with BOSL2 )

Self-intersections shouldn't be an issue for most cases as long as "r2" is somewhat larger than "radius".

oh and i decided to name your shape a "squiggy"

include<BOSL2/std.scad>
include<BOSL2/skin.scad>

radius=4;
sections = 6;
r2 = radius*2;

$fs=0.5;
$fa=1;

arcs = 2*sections;
a_ext = 180+360/arcs;
a_int = 360 - a_ext;
R_c = r2/sin(180/arcs); // radius of circle which squiggy centers lie on

squiggy_points = [
  for(i=[0:1:arcs-1]) let(a_c=360*i/arcs)
    if (i%2) each my_arc(r=r2, angle=a_ext, offsetAngle=0+a_c, c=R_c*[cos(a_c),sin(a_c)], center=true, endpoint=false)
    else each my_arc(r=r2, angle=-a_int, offsetAngle=180+a_c, c=R_c*[cos(a_c),sin(a_c)], center=true, endpoint=false)
];

path_sweep(circle(r=radius), squiggy_points, closed=true);

// Generate a list of points for a circular arc with center c, radius r, etc.
// "center" parameter centers the sweep of the arc about the offsetAngle (half to each side of it)
// "internal" parameter enables polyhole radius correction
// optional "d" parameter overrides r
// optional "fragments" parameter overrides calculations from $fn,$fs,$fa with a direct input
// optional "endpoint" parameter specifies whether or not to include the last point in the arc,
//    by default the endpoint is included as long as the angle is not 360
//    setting endpoint=false can be useful to avoid duplicating points if you are concatenating arc paths together
function my_arc(r=1, angle=360, offsetAngle=0, c=[0,0], center=false, internal=false, d, fragments, endpoint) =
  let (
    r1 = d==undef ? r : d/2,
    fragments = fragments==undef ? ceil((abs(angle) / 360) * fragments(r1)) : fragments,
    step = angle / fragments,
    a = offsetAngle-(center ? angle/2 : 0),
    R = internal ? to_internal(r1) : r1,
    last = endpoint==undef ? (abs(angle) == 360 ? 1 : 0) : (endpoint ? 0 : 1)
  )
  [ for (i = [0:1:fragments-last] ) let(a2=i*step+a) c+R*[cos(a2), sin(a2)] ];

function fragments(r=1) = ($fn > 0) ? ($fn >= 3 ? $fn : 3) : ceil(max(min(360.0 / $fa, r*2*PI / $fs), 5));




On Thu, Dec 10, 2020 at 9:43 PM adrianv <[hidden email]> wrote:
Nobody posted an example of what I thought was desired:

include<BOSL2/std.scad>
include<BOSL2/skin.scad>

$fn=16;
ofs = 1;
r=4;
number=5;
radius=.4;     // If this is much bigger you need path_sweep2d

path = [for(i=[0:2:359]) (r+ofs*sin(number*i))*[cos(i),sin(i)]];
path_sweep(circle(r=radius), path, closed=true);
// path_sweep2d(circle(r=radius), path, closed=true);

Note that if you fiddle with the parameters you can get self-intersections
to occur at the peaks of the sin wave (creases in the model) and that makes
the model invalid.  (Curiously the RC version doesn't flag this as invalid,
even though the render is wrong!)  You can  handle the self-intersections
with path_sweep2d, but it's much slower, at least to preview, than the
regular path_sweep. 

BOSL2 is the Belfry OpenSCAD Library: 

https://github.com/revarbat/BOSL2/wiki

I believe the dotSCAD library also includes a path_sweep module (not sure
what it's called).   And of course list-comprehension-demos has the original
sweep(). 


skypuppy wrote
> I'd like to know what it is before I jump down that rabbit hole.
>
> David
>
>
> On 12/10/20 8:18 PM, crunchysteve wrote:
>> Answered "What is BOSL2?" for myself, disregard that question :D
>>
>> Cheers
>>
>>
>>
>> -----
>> Make things, travel and tell stories.
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

squiggy.png (183K) Download Attachment