slow render

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

slow render

David Eccles (gringer)
From: kitwallace <[hidden email]>
> 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)

There are a few of these already on Thingiverse. This one uses OpenSCAD to generate them by using the hull function:

http://www.thingiverse.com/thing:210347

I also wrote a path extrusion function (perl code) that sort of works for these knots, but you get some weird twists about half way along
because I haven't worked out how to do appropriate pre-rotation of the extruded polygon:

http://www.thingiverse.com/thing:186660

Someone else mentioned on this list that they're implementing something like path extrusion in OpenSCAD via a loft function:

https://github.com/openscad/openscad/wiki/OEP1%3A-Generalized-extrusion-module

- David


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: slow render

nophead
Here is a version of the knot that takes 16 minutes to render with a step size of 2 and looks reasonably smooth. Instead of a cylinder between each pair of points I place a disc mid way between them. I then hull adjacent disks.

To approximate a 2D disk I use a very flat cone (a cylinder with r2 = 0).  If that only has one point at its vertex it will almost halve the number of points hull has to consider (compared to using a short cylinder).

pi = 3.14159;

module disc_p2p(p1, p2, r) {
      assign(p = p2 - p1)
      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])
      render() cylinder(h = 0.1, r1 = r, r2 = 0);
};

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: 359])
       assign (p0 = f(a,b,t), 
               p1 = f(a,b,t + step ),
               p2 = f(a,b,t + 2 * step))
hull() {
          disc_p2p (p0,p1,r);
          disc_p2p (p1,p2,r);   
}
};

$fn=20;
a = 0.8;
scale(15) tube (a, sqrt (1 - a * a), 0.3, 2);



On 20 January 2014 22:28, David Eccles (gringer) <[hidden email]> wrote:
From: kitwallace <[hidden email]>
> 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)

There are a few of these already on Thingiverse. This one uses OpenSCAD to generate them by using the hull function:

http://www.thingiverse.com/thing:210347

I also wrote a path extrusion function (perl code) that sort of works for these knots, but you get some weird twists about half way along
because I haven't worked out how to do appropriate pre-rotation of the extruded polygon:

http://www.thingiverse.com/thing:186660

Someone else mentioned on this list that they're implementing something like path extrusion in OpenSCAD via a loft function:

https://github.com/openscad/openscad/wiki/OEP1%3A-Generalized-extrusion-module

- David


_______________________________________________
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/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: slow render

szabi
I'm impressed!

Szelp, André Szabolcs

+43 (650) 79 22 400


On Tue, Jan 21, 2014 at 12:09 AM, nop head <[hidden email]> wrote:
Here is a version of the knot that takes 16 minutes to render with a step size of 2 and looks reasonably smooth. Instead of a cylinder between each pair of points I place a disc mid way between them. I then hull adjacent disks.

To approximate a 2D disk I use a very flat cone (a cylinder with r2 = 0).  If that only has one point at its vertex it will almost halve the number of points hull has to consider (compared to using a short cylinder).

pi = 3.14159;

module disc_p2p(p1, p2, r) {
      assign(p = p2 - p1)
      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])
      render() cylinder(h = 0.1, r1 = r, r2 = 0);
};

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: 359])
       assign (p0 = f(a,b,t), 
               p1 = f(a,b,t + step ),
               p2 = f(a,b,t + 2 * step))
hull() {
          disc_p2p (p0,p1,r);
          disc_p2p (p1,p2,r);   
}
};

$fn=20;
a = 0.8;
scale(15) tube (a, sqrt (1 - a * a), 0.3, 2);



On 20 January 2014 22:28, David Eccles (gringer) <[hidden email]> wrote:
From: kitwallace <[hidden email]>
> 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)

There are a few of these already on Thingiverse. This one uses OpenSCAD to generate them by using the hull function:

http://www.thingiverse.com/thing:210347

I also wrote a path extrusion function (perl code) that sort of works for these knots, but you get some weird twists about half way along
because I haven't worked out how to do appropriate pre-rotation of the extruded polygon:

http://www.thingiverse.com/thing:186660

Someone else mentioned on this list that they're implementing something like path extrusion in OpenSCAD via a loft function:

https://github.com/openscad/openscad/wiki/OEP1%3A-Generalized-extrusion-module

- David


_______________________________________________
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/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: slow render

kitwallace
In reply to this post by nophead
Thats a great idea to use a cone instead of a short cylinder- it also means you don't have to compute an appropriate disk height per disk.

With a step-size of 2, your code rendered in 12 minutes, more than twice as fast as my spheres did.  

I've updated  http://www.thingiverse.com/thing:230557 with this code.  I'm really pleased to see that mathgrrl made a  nice print of an earlier version.

(BTW pi is litter from some previous experiment)