# slow render

53 messages
123
Open this post in threaded view
|

## slow render

 I'm trying to create a knot ( a rolling trefoil - http://makerhome.blogspot.co.uk/2013/12/day-110-rocking-knot.html ) with this code using version 2013.06 . (It constructs a tube as a sequence of cylinders oriented along the parametric path) pi = 3.14159; function length(p) = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[1],3)); module cylinder_p2p(p1, p2, r) {       assign(p = p2 - p1)       assign(distance = length(p))       translate(p1 + p/2)       rotate([0, 0, atan2(p[1], p[0])])       rotate([0, atan2(sqrt(pow(p[0], 2)+pow(p[1], 2)),p[2]), 0])       cylinder(h = distance, r = r,center=true); }; function f(a,b,t) =   // rolling knot    [ a * cos (3 * t) / (1 - b* sin (2 *t)),      a * sin( 3 * t) / (1 - b* sin (2 *t)),      1.8 * b * cos (2 * t) /(1 - b* sin (2 *t))    ]; module tube(a, b, r, step) {    for (t=[0: step: 361]) {        assign (p0 = f(a,b,t))        assign (p1 = f(a,b,t +2* step ))           cylinder_p2p (p0,p1,r);    } }; \$fn=20; a = 0.8; scale(15) tube (a, sqrt (1 - a * a), 0.3, 1); F5 generates a view instantly, but F6 is very slow : based on timings for N (cylinders) = 2,4.. 20, I get N^2 *0.8  which for 360 would be 25 hours Any  suggestions ?
Open this post in threaded view
|

## Re: slow render

 Administrator On Jan 20, 2014, at 10:02 AM, kitwallace <[hidden email]> wrote: > I'm trying to create a knot ( a rolling trefoil - > http://makerhome.blogspot.co.uk/2013/12/day-110-rocking-knot.html ) with > this code using version 2013.06 . (It constructs a tube as a sequence of > cylinders oriented along the parametric path) This is close to worst-case scenario for OpenSCAD. See here for an early discussion on more flexible extrusion in OpenSCAD which would help in your case: https://github.com/openscad/openscad/wiki#more-general-extrusion-module -Marius _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

 In reply to this post by nophead Thanks nophead -yes to my chagrin I spotted that silly typo  as I experimented with different ways of joining the segments. I overlap the cylinders by a factor of 2 in an attempt to avoid gaps  and also reduce the step size - but that merely makes the full render performance worse of course. I tried hulling pairs of adjacent cylinders (disks) : F5 performance is much slower but F6 is much better - seems almost NlogN . I tried spheres (which don't need orienting of course).  This give the best performance and a simpler script.  2 degree resolution still took 28 minutes on my laptop but acceptable. The work is now published http://www.thingiverse.com/thing:230557Perhaps what would be nice would be if linear_extrude had a function parameter so the cross-section could be computed at each step in the extrusion.
Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

 Administrator In reply to this post by szabi szabi wrote These performance numbers (nlogn, n^2) for respective operations really should be documented somewhere, You probably need to log your system config too, particularly OpenSCAD cache sizes/render limit. Has anyone with longer running models made sure their cache size is large enough? Just a thought... Admin - email* me if you need anything, or if I've done something stupid... * 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.
Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

 I think nop head's idea of a cone creates the minimal number of faces for a given resolution and much fewer than a sphere.   My own timings support that view but I will redo them carefully to check that both are still O(N^2) as would be expected.
Open this post in threaded view
|

## Re: slow render

Open this post in threaded view
|

## Re: slow render

 Well I'm really puzzled :  I thought I'd minimise the facets on the hulled cylinder by reversing the direction of the second cone so both point inwards  which should reduce the cylinder faces from 2N + 2 to N + 2 (modulo the proportion of faces split due to twist)  Instead the time inceases by a factor of 3! and (the number of vertices has gone up by 3 . This seems to be because the cylinder ends dont quite match.  I assume this is  rounding error because the face has been reversed?
Open this post in threaded view
|

## Re: slow render

 In reply to this post by nophead >  So when adding tubes end to end the time should be linear as all the action happens at the junction. Not so in general  - for example tubes like the ones here in a torus knot http://www.thingiverse.com/thing:231727
Open this post in threaded view
|

## Re: slow render

 In reply to this post by kitwallace Yes I am currently investigating the effect of reversing the cones. Flat ended cylinders appear to take a lot longer than ones that have a point on one end that penetrates the next one. On 22 January 2014 14:39, kitwallace wrote: Well I'm really puzzled :  I thought I'd minimise the facets on the hulled cylinder by reversing the direction of the second cone so both point inwards which should reduce the cylinder faces from 2N + 2 to N + 2 (modulo the proportion of faces split due to twist)  Instead the time inceases by a factor of 3! and (the number of vertices has gone up by 3 . This seems to be because the cylinder ends dont quite match.  I assume this is  rounding error because the face has been reversed? -- View this message in context: http://forum.openscad.org/slow-render-tp6556p6606.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad http://openscad.org - https://flattr.com/thing/121566 _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566