discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Tips to keep the speed acceptable

P
Parkinbot
Mon, Dec 7, 2015 12:50 PM

Johan Jonker wrote

Any idea for another way to draw this?

Well, have a look at the sweep renderer shown in
http://www.thingiverse.com/thing:900137
Instead of feeding in a NACA profile, you'd just create a circle (or any
other 2D-shape). Building on the scheme shown in example2() the code is as
fast as it can get in OpenSCAD (especially for CGAL)

You also might be interested to use an interpolation scheme, which makes the
path calculation for your thing very convenient
http://forum.openscad.org/general-extrusion-imperfect-tp14740p14758.html
respectively
http://forum.openscad.org/general-extrusion-imperfect-tp14740p14758.html

I've ported the nSpline library, but yet did'nt have time to connect it with
my sweep renderer in OpenSCAD and to publish it.

Rudolf

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15008.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Johan Jonker wrote > Any idea for another way to draw this? Well, have a look at the sweep renderer shown in http://www.thingiverse.com/thing:900137 Instead of feeding in a NACA profile, you'd just create a circle (or any other 2D-shape). Building on the scheme shown in example2() the code is as fast as it can get in OpenSCAD (especially for CGAL) You also might be interested to use an interpolation scheme, which makes the path calculation for your thing very convenient http://forum.openscad.org/general-extrusion-imperfect-tp14740p14758.html respectively http://forum.openscad.org/general-extrusion-imperfect-tp14740p14758.html I've ported the nSpline library, but yet did'nt have time to connect it with my sweep renderer in OpenSCAD and to publish it. Rudolf -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15008.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Mon, Dec 7, 2015 5:24 PM

I changed the delta into a variable one:

/module calyx(buiten)
{
delta = 2;
delta2 = delta/2;
delta3 = delta2/2;
delta4 = delta3/2;
for (height = [0:delta:maxheight-4delta])
{
calyx_segment(height, delta, buiten);
}
for (height = [maxheight-4
delta:delta2:maxheight-4delta2])
{
calyx_segment(height, delta2, buiten);
}
for (height = [maxheight-4
delta2:delta3:maxheight-4delta3])
{
calyx_segment(height, delta3, buiten);
}
for (height = [maxheight-4
delta3:delta4:maxheight-delta4])
{
calyx_segment(height, delta4, buiten);
}
}/

And also corrected the culculations for the thickness. It is a dy/dx of a
power to 4: (y = B -x^4*A)

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15016.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I changed the delta into a variable one: /module calyx(buiten) { delta = 2; delta2 = delta/2; delta3 = delta2/2; delta4 = delta3/2; for (height = [0:delta:maxheight-4*delta]) { calyx_segment(height, delta, buiten); } for (height = [maxheight-4*delta:delta2:maxheight-4*delta2]) { calyx_segment(height, delta2, buiten); } for (height = [maxheight-4*delta2:delta3:maxheight-4*delta3]) { calyx_segment(height, delta3, buiten); } for (height = [maxheight-4*delta3:delta4:maxheight-delta4]) { calyx_segment(height, delta4, buiten); } }/ And also corrected the culculations for the thickness. It is a dy/dx of a power to 4: (y = B -x^4*A) -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15016.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Mon, Dec 7, 2015 6:47 PM

@ parkinbot: Interesting this sweep function. And it is indeed fast.
But it's a little to complicate for a beginner like me to implement now.

@neon22. The delta error is corrected nog. This is the result at this
moment.
Rendering the inside and the outside with $fn= 100 took about 20 minutes.
http://forum.openscad.org/file/n15019/kelk.jpg

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15019.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

@ parkinbot: Interesting this sweep function. And it is indeed fast. But it's a little to complicate for a beginner like me to implement now. @neon22. The delta error is corrected nog. This is the result at this moment. Rendering the inside and the outside with $fn= 100 took about 20 minutes. <http://forum.openscad.org/file/n15019/kelk.jpg> -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15019.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MS
Mark Schafer
Mon, Dec 7, 2015 6:51 PM

very beautiful

On 12/8/2015 7:47 AM, Johan Jonker wrote:

@ parkinbot: Interesting this sweep function. And it is indeed fast.
But it's a little to complicate for a beginner like me to implement now.

@neon22. The delta error is corrected nog. This is the result at this
moment.
Rendering the inside and the outside with $fn= 100 took about 20 minutes.
http://forum.openscad.org/file/n15019/kelk.jpg

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15019.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7227 / Virus Database: 4477/11133 - Release Date: 12/07/15

very beautiful On 12/8/2015 7:47 AM, Johan Jonker wrote: > @ parkinbot: Interesting this sweep function. And it is indeed fast. > But it's a little to complicate for a beginner like me to implement now. > > @neon22. The delta error is corrected nog. This is the result at this > moment. > Rendering the inside and the outside with $fn= 100 took about 20 minutes. > <http://forum.openscad.org/file/n15019/kelk.jpg> > > > > -- > View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15019.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2016.0.7227 / Virus Database: 4477/11133 - Release Date: 12/07/15 > >
JJ
Johan Jonker
Mon, Dec 7, 2015 9:03 PM

For anyone who likes the end result.
I generate the file twice and then substract them in an other scad file.
It is also in this file but takes too long to render (even F5).

// object: bass clarinet bell
// version: 4
// design: J.G.Jonker
// website: sax.jonker.co
// date: 7-12-2015
$fn=100;
maxheight = 150;
d_btm_inside = 41;
d_btm_wall =17.5;
d_top_inside = 138;
d_top_wall = 4;
t_top = 60;
rotatie_top = 45;
mildfactor = 0.5;
h_tenon = 5;
//---------------
astraal = maxheight/sin(rotatie_top);

    difference()
    {
        // translate([0,0,-150]) calyx(buiten=true); 
        translate([0,0,-150]) calyx(buiten=false); 
    }

module calyx(buiten)
{
delta = 2;
delta2 = delta/2;
delta3 = delta2/2;
delta4 = delta3/2;
for (height = [0:delta:maxheight-4delta])
{
calyx_segment(height, delta, buiten,0);
}
for (height = [maxheight-7
delta2:delta2:maxheight-4delta2])
{
calyx_segment(height, delta2, buiten,0);
}
for (height = [maxheight-7
delta3:delta3:maxheight-4delta3])
{
calyx_segment(height, delta3, buiten,0);
}
for (height = [maxheight-7
delta4:delta4:maxheight-2*delta4])
{
calyx_segment(height, delta4, buiten,0);
}
for (height = [maxheight-delta4:delta4:maxheight-delta4])
{
calyx_segment(height, delta4, buiten,d_top_wall);
}
}

module calyx_segment(height,delta,buiten,top)
{
percentage = height/maxheight;
percentage2 = (height+delta)/maxheight;
//
d_inside    = d_top_inside
- pow((1-percentage),0.25)* (d_top_inside -
d_btm_inside);
d_inside2  = d_top_inside
- pow((1-percentage2),0.25)* (d_top_inside -
d_btm_inside);
rc          = atan(4maxheightpow((d_top_inside -
d_btm_inside),-4)* pow(d_top_inside - d_inside,3));
rc2        = atan(4maxheightpow((d_top_inside -
d_btm_inside),-4)* pow(d_top_inside-d_inside2,3));
//-------------------------------------------------------------
// determine de wall thickness
// keep the outside straight until d_top_wall is reached
//------------------------------------------------------------
d_wall      = (d_inside + d_top_wall) < (d_btm_inside+d_btm_wall) ?
(d_btm_inside+d_btm_wall - d_inside):
d_top_wall;
d_wall2    = (d_inside2 + d_top_wall) < (d_btm_inside+d_btm_wall) ?
(d_btm_inside+d_btm_wall - d_inside2):
d_top_wall;

    dx_raw      = (d_inside2-d_inside)/2;
    s_raw       = sqrt(dx_raw*dx_raw+delta*delta);
    dx1          = d_wall * sin(rc);
    dx2          = d_wall * sin(rc2);
    dy1           = d_wall * cos(rc);
    dy2          = d_wall * cos(rc2);
    //echo("delta's", rc,rc2,dx1,dx2,dy1,dy2);
    //echo("y x", d_inside, d_inside2, height, height+delta);
    //echo("hoek", hoek, hoek2);
    hoek = rotatie_top*percentage;
    hoek2 = rotatie_top*percentage2;
        
    if (buiten == true)
        {                      
            cylinder_pie(hoek, hoek2, 
                    -astraal*(1-cos(hoek*percentage))*mildfactor,
                    -astraal*(1-cos(hoek2*percentage2))*mildfactor,
                    height-dy1,

height+delta-dy2,d_inside/2+dx1,d_inside2/2+dx2,top,0);
}
else
{
cylinder_pie(hoek, hoek2,
-astraal*(1-cos(hoekpercentage))mildfactor,
-astraal
(1-cos(hoek2
percentage2))*mildfactor,
height, height+delta,d_inside/2,d_inside2/2,top,4);
}
}

module cylinder_pie(angle1, angle2, dx1,dx2,dy1,dy2,r1,r2,top,dr)
{
// draw top and bottom cylinders
// rotate the cylinder
// hull the cylinders
// trick: draw an extra thick and large cylinder when the top is
reached and
d=0.01;
//echo("top", top,dr);
hull()
{

             translate([ 0,dx1,dy1])
             rotate( angle1, ([1,0,0]))
             translate([0,0,-d])
             cylinder(d,r1, r1, center=false);
           
             translate([ 0,dx2,dy2])
             rotate( angle2, ([1,0,0]))
             translate([0,0,d])  
             cylinder(d+top,r2, r2, center=false);

      }
      if (top > 0)
      {
             translate([ 0,dx2,dy2])
             rotate( angle2, ([1,0,0]))
             translate([0,0,d])  
             cylinder(d+top,r2+dr, r2+dr, center=false);
          
}

}

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15025.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

For anyone who likes the end result. I generate the file twice and then substract them in an other scad file. It is also in this file but takes too long to render (even F5). // object: bass clarinet bell // version: 4 // design: J.G.Jonker // website: sax.jonker.co // date: 7-12-2015 $fn=100; maxheight = 150; d_btm_inside = 41; d_btm_wall =17.5; d_top_inside = 138; d_top_wall = 4; t_top = 60; rotatie_top = 45; mildfactor = 0.5; h_tenon = 5; //--------------- astraal = maxheight/sin(rotatie_top); difference() { // translate([0,0,-150]) calyx(buiten=true); translate([0,0,-150]) calyx(buiten=false); } module calyx(buiten) { delta = 2; delta2 = delta/2; delta3 = delta2/2; delta4 = delta3/2; for (height = [0:delta:maxheight-4*delta]) { calyx_segment(height, delta, buiten,0); } for (height = [maxheight-7*delta2:delta2:maxheight-4*delta2]) { calyx_segment(height, delta2, buiten,0); } for (height = [maxheight-7*delta3:delta3:maxheight-4*delta3]) { calyx_segment(height, delta3, buiten,0); } for (height = [maxheight-7*delta4:delta4:maxheight-2*delta4]) { calyx_segment(height, delta4, buiten,0); } for (height = [maxheight-delta4:delta4:maxheight-delta4]) { calyx_segment(height, delta4, buiten,d_top_wall); } } module calyx_segment(height,delta,buiten,top) { percentage = height/maxheight; percentage2 = (height+delta)/maxheight; // d_inside = d_top_inside - pow((1-percentage),0.25)* (d_top_inside - d_btm_inside); d_inside2 = d_top_inside - pow((1-percentage2),0.25)* (d_top_inside - d_btm_inside); rc = atan(4*maxheight*pow((d_top_inside - d_btm_inside),-4)* pow(d_top_inside - d_inside,3)); rc2 = atan(4*maxheight*pow((d_top_inside - d_btm_inside),-4)* pow(d_top_inside-d_inside2,3)); //------------------------------------------------------------- // determine de wall thickness // keep the outside straight until d_top_wall is reached //------------------------------------------------------------ d_wall = (d_inside + d_top_wall) < (d_btm_inside+d_btm_wall) ? (d_btm_inside+d_btm_wall - d_inside): d_top_wall; d_wall2 = (d_inside2 + d_top_wall) < (d_btm_inside+d_btm_wall) ? (d_btm_inside+d_btm_wall - d_inside2): d_top_wall; dx_raw = (d_inside2-d_inside)/2; s_raw = sqrt(dx_raw*dx_raw+delta*delta); dx1 = d_wall * sin(rc); dx2 = d_wall * sin(rc2); dy1 = d_wall * cos(rc); dy2 = d_wall * cos(rc2); //echo("delta's", rc,rc2,dx1,dx2,dy1,dy2); //echo("y x", d_inside, d_inside2, height, height+delta); //echo("hoek", hoek, hoek2); hoek = rotatie_top*percentage; hoek2 = rotatie_top*percentage2; if (buiten == true) { cylinder_pie(hoek, hoek2, -astraal*(1-cos(hoek*percentage))*mildfactor, -astraal*(1-cos(hoek2*percentage2))*mildfactor, height-dy1, height+delta-dy2,d_inside/2+dx1,d_inside2/2+dx2,top,0); } else { cylinder_pie(hoek, hoek2, -astraal*(1-cos(hoek*percentage))*mildfactor, -astraal*(1-cos(hoek2*percentage2))*mildfactor, height, height+delta,d_inside/2,d_inside2/2,top,4); } } module cylinder_pie(angle1, angle2, dx1,dx2,dy1,dy2,r1,r2,top,dr) { // draw top and bottom cylinders // rotate the cylinder // hull the cylinders // trick: draw an extra thick and large cylinder when the top is reached and d=0.01; //echo("top", top,dr); hull() { translate([ 0,dx1,dy1]) rotate( angle1, ([1,0,0])) translate([0,0,-d]) cylinder(d,r1, r1, center=false); translate([ 0,dx2,dy2]) rotate( angle2, ([1,0,0])) translate([0,0,d]) cylinder(d+top,r2, r2, center=false); } if (top > 0) { translate([ 0,dx2,dy2]) rotate( angle2, ([1,0,0])) translate([0,0,d]) cylinder(d+top,r2+dr, r2+dr, center=false); } } -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15025.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Tue, Dec 8, 2015 12:51 AM

With the code as-is I get a nice horn shape.
E.g. set $fn to 12 on first line for faster results.

But I get a bad object if I change "buiten=true" over in the difference loop
and get the other surface.
I.e.
difference()  {
translate([0,0,-150]) calyx(buiten=true);
// translate([0,0,-150]) calyx(buiten=false);
}
The nice bell shape is gone. I've tracked it to the first region in calcyx:
for (height = [0:delta:maxheight-4*delta])
calyx_segment(height, delta, buiten,0);
http://forum.openscad.org/file/n15026/bell-2.png

But I can't see the bug.
(For me, at low $fn the difference goes pretty fast, and only 20 sec for
$fn=100.
but the resulting object is super slow in camera due to large number of
surfaces.
The Render() takes a very long time (48sec for $fn=12)  even for single
surface.)

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15026.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

With the code as-is I get a nice horn shape. E.g. set $fn to 12 on first line for faster results. But I get a bad object if I change "buiten=true" over in the difference loop and get the other surface. I.e. difference() { translate([0,0,-150]) calyx(buiten=true); // translate([0,0,-150]) calyx(buiten=false); } The nice bell shape is gone. I've tracked it to the first region in calcyx: for (height = [0:delta:maxheight-4*delta]) calyx_segment(height, delta, buiten,0); <http://forum.openscad.org/file/n15026/bell-2.png> But I can't see the bug. (For me, at low $fn the difference goes pretty fast, and only 20 sec for $fn=100. but the resulting object is super slow in camera due to large number of surfaces. The Render() takes a very long time (48sec for $fn=12) even for single surface.) -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15026.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Tue, Dec 8, 2015 7:57 AM

This will fix the bug:

    d_wall      = ((d_inside + d_top_wall) < (d_btm_inside+d_btm_wall) ? 
                    (d_btm_inside+d_btm_wall - d_inside): 
                    d_top_wall)/2;
    d_wall2     = ((d_inside2 + d_top_wall) < (d_btm_inside+d_btm_wall)

?
(d_btm_inside+d_btm_wall - d_inside2):
d_top_wall)/2;

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15028.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

This will fix the bug: d_wall = ((d_inside + d_top_wall) < (d_btm_inside+d_btm_wall) ? (d_btm_inside+d_btm_wall - d_inside): d_top_wall)/2; d_wall2 = ((d_inside2 + d_top_wall) < (d_btm_inside+d_btm_wall) ? (d_btm_inside+d_btm_wall - d_inside2): d_top_wall)/2; -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15028.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Tue, Dec 8, 2015 10:41 AM

Found it - it was this:
dx1    = d_wall * sin(rc);
dx2    = d_wall2 * sin(rc2);
dy1    = d_wall * cos(rc);
dy2    = d_wall2 * cos(rc2);
They were d_wall and not d_wall2

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15029.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Found it - it was this: dx1 = d_wall * sin(rc); dx2 = d_wall2 * sin(rc2); dy1 = d_wall * cos(rc); dy2 = d_wall2 * cos(rc2); They were d_wall and not d_wall2 -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15029.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Tue, Dec 8, 2015 8:02 PM

Yes are very right, that was also wrong.

Another thing is that I see small white dots in the object. I thougth that
everything is done to make it watertight. Also when I import all SLT files
sometime a large hole appears in the object depending on the angle that the
object is viewed. Is it in bug in OpenScad or in my design?

http://forum.openscad.org/file/n15037/waterdicht.jpg
http://forum.openscad.org/file/n15037/waterdicht2.jpg

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15037.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Yes are very right, that was also wrong. Another thing is that I see small white dots in the object. I thougth that everything is done to make it watertight. Also when I import all SLT files sometime a large hole appears in the object depending on the angle that the object is viewed. Is it in bug in OpenScad or in my design? <http://forum.openscad.org/file/n15037/waterdicht.jpg> <http://forum.openscad.org/file/n15037/waterdicht2.jpg> -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15037.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Tue, Dec 8, 2015 8:10 PM

Have you set the convexity parameter to import?

On 8 December 2015 at 20:02, Johan Jonker johangjonker@zonnet.nl wrote:

Yes are very right, that was also wrong.

Another thing is that I see small white dots in the object. I thougth that
everything is done to make it watertight. Also when I import all SLT files
sometime a large hole appears in the object depending on the angle that the
object is viewed. Is it in bug in OpenScad or in my design?

http://forum.openscad.org/file/n15037/waterdicht.jpg
http://forum.openscad.org/file/n15037/waterdicht2.jpg

--
View this message in context:
http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15037.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Have you set the convexity parameter to import? On 8 December 2015 at 20:02, Johan Jonker <johangjonker@zonnet.nl> wrote: > Yes are very right, that was also wrong. > > > Another thing is that I see small white dots in the object. I thougth that > everything is done to make it watertight. Also when I import all SLT files > sometime a large hole appears in the object depending on the angle that the > object is viewed. Is it in bug in OpenScad or in my design? > > <http://forum.openscad.org/file/n15037/waterdicht.jpg> > <http://forum.openscad.org/file/n15037/waterdicht2.jpg> > > > > > > -- > View this message in context: > http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15037.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >