sweeping over a list of objects?

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

sweeping over a list of objects?

bboett
hello!
 and thanks a lot for the help with the iaito, that one went really well!

this gave me the impulsion to try another one of my projects, i want to make a hook, but at the moment i hit a performance problem....
i just started and i have preview rendering times of several minutes.....

i heavily suspect that there is a more efficient way to achieve this?
the sweep function needs polygons, but polygons, are, well, pointy.....
that's why i tried it with the 2D shapes and hull... but as is, dev on it is very complicated..... and other than to buy a more powerful comp.....

this is what i tried:

radius = 15;
step = 5;
//quers(d1 = 2, d2 = 1.5*2, 2, maxb = 5);

for(angle = [0:step:110])
{
  hull()
  {
    rotate([angle,0,0])
      translate([0,radius,0])
      linear_extrude(height = .1)quers(d1 = minrad(angle), d2 = 1.5*minrad(angle), minrad(angle), maxb = 5);
    rotate([angle+step,0,0])
      translate([0,radius,0])
      linear_extrude(height = .1)quers(d1 = minrad(angle+step), d2 = 1.5*minrad(angle+step), minrad(angle+step), maxb = 5);
  }
}

function minrad(alpha) = -1/30*alpha +5;
module quers(d1 = 2, d2 = 4, h= 2, maxb = 0)
{
  $fn = 200;
 hull()
  {
    if(maxb > 0)
    {
      difference()
      {
        union()
        {
          translate([0,h/2,0]) circle(d = d2);
          translate([0,-h/2,0]) circle(d = d1);
        }
        union()
        {
          translate([1.9*h,-h/2,0]) rotate([0,0,-atan((d2-d1)/h)/2])color("red") square(3*h,h,center = true);
          translate([-1.9*h,-h/2,0]) rotate([0,0,atan((d2-d1)/h)/2])color("red") square(3*h,h,center = true);
        }
      }
    }
    else
    {
      translate([0,h/2,0]) circle(d = d2);
      translate([0,-h/2,0]) circle(d = d1);
    }
  }
}//module quers(d1 = 2, d2 = 4 )


--
ciao
Bruno

===========================================
http://nohkumado.eu/, http://aikido.nohkumado.eu/,
http://aikido.zorn.free.fr

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

Re: sweeping over a list of objects?

nophead
It only takes six second to preview with OpenSCAD 2019.05. I had to fix the missing [ ] in the square calls first. I.e.

          translate([1.9*h,-h/2,0]) rotate([0,0,-atan((d2-d1)/h)/2])color("red") square([3*h,h],center = true);
          translate([-1.9*h,-h/2,0]) rotate([0,0,atan((d2-d1)/h)/2])color("red") square([3*h,h],center = true);

 F6 takes 1 minute 53 seconds, which doesn't seem bad for something with $fn = 200.

On Wed, 22 Apr 2020 at 10:13, Bruno Boettcher <[hidden email]> wrote:
hello!
 and thanks a lot for the help with the iaito, that one went really well!

this gave me the impulsion to try another one of my projects, i want to make a hook, but at the moment i hit a performance problem....
i just started and i have preview rendering times of several minutes.....

i heavily suspect that there is a more efficient way to achieve this?
the sweep function needs polygons, but polygons, are, well, pointy.....
that's why i tried it with the 2D shapes and hull... but as is, dev on it is very complicated..... and other than to buy a more powerful comp.....

this is what i tried:

radius = 15;
step = 5;
//quers(d1 = 2, d2 = 1.5*2, 2, maxb = 5);

for(angle = [0:step:110])
{
  hull()
  {
    rotate([angle,0,0])
      translate([0,radius,0])
      linear_extrude(height = .1)quers(d1 = minrad(angle), d2 = 1.5*minrad(angle), minrad(angle), maxb = 5);
    rotate([angle+step,0,0])
      translate([0,radius,0])
      linear_extrude(height = .1)quers(d1 = minrad(angle+step), d2 = 1.5*minrad(angle+step), minrad(angle+step), maxb = 5);
  }
}

function minrad(alpha) = -1/30*alpha +5;
module quers(d1 = 2, d2 = 4, h= 2, maxb = 0)
{
  $fn = 200;
 hull()
  {
    if(maxb > 0)
    {
      difference()
      {
        union()
        {
          translate([0,h/2,0]) circle(d = d2);
          translate([0,-h/2,0]) circle(d = d1);
        }
        union()
        {
          translate([1.9*h,-h/2,0]) rotate([0,0,-atan((d2-d1)/h)/2])color("red") square(3*h,h,center = true);
          translate([-1.9*h,-h/2,0]) rotate([0,0,atan((d2-d1)/h)/2])color("red") square(3*h,h,center = true);
        }
      }
    }
    else
    {
      translate([0,h/2,0]) circle(d = d2);
      translate([0,-h/2,0]) circle(d = d1);
    }
  }
}//module quers(d1 = 2, d2 = 4 )


--
ciao
Bruno

===========================================
http://nohkumado.eu/, http://aikido.nohkumado.eu/,
http://aikido.zorn.free.fr
_______________________________________________
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
tp3
Reply | Threaded
Open this post in threaded view
|

Re: sweeping over a list of objects?

tp3
In reply to this post by bboett
On 22.04.20 11:12, Bruno Boettcher wrote:
> i just started and i have preview rendering times of
> several minutes.....

Are we talking about the exact code below? That's
finishing preview in 3 seconds. I guess actual render
will be quite slow due to the high $fn count.

Just using a general already quite high resolution of
$fa = 2; $fs = 0.2; at the top of the script instead
of the $fn = 200; previews in 0 seconds and renders
in 19 though.

Note that the slightly strange warning is due to
square([3*h,h],center = true); missing the [ ] so
the 2nd h is where the positional argument center
is.

ciao,
  Torsten.

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

Re: sweeping over a list of objects?

bboett
indeed....
adding the brackets i am down to 34s.....
no error message though.....

i have still 2019.01-RC2 , the one shipped with my distro....

and missing the long awaited svg import :( still waiting....


still, if there are suggestions on how to achieve this in a better way, i take them :D


ciao

Bruno


Am Mi., 22. Apr. 2020 um 11:52 Uhr schrieb Torsten Paul <[hidden email]>:
On 22.04.20 11:12, Bruno Boettcher wrote:
> i just started and i have preview rendering times of
> several minutes.....

Are we talking about the exact code below? That's
finishing preview in 3 seconds. I guess actual render
will be quite slow due to the high $fn count.

Just using a general already quite high resolution of
$fa = 2; $fs = 0.2; at the top of the script instead
of the $fn = 200; previews in 0 seconds and renders
in 19 though.

Note that the slightly strange warning is due to
square([3*h,h],center = true); missing the [ ] so
the 2nd h is where the positional argument center
is.

ciao,
  Torsten.

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


--
ciao
Bruno

===========================================
http://nohkumado.eu/, http://aikido.nohkumado.eu/,
http://aikido.zorn.free.fr

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

Re: sweeping over a list of objects?

tp3
On 22.04.20 15:07, Bruno Boettcher wrote:
> i have still 2019.01-RC2, the one shipped with my distro....

You can also check out the AppImage or install via flatpak.

ciao,
  Torsten.


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