discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

F5 works, but not F6

J
jon
Sun, Jun 14, 2015 12:35 AM

I can get this to work with F5, but not with F6: it just hangs for
hours, running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}

I can get this to work with F5, but not with F6: it just hangs for hours, running full CPU. Any thoughts? rch = 0.1; ballDiam = 25.4 * 1/4 + rch; $fn = 50; module spiral() { myScale = 1/40; hubR = 5; for (d = [0:1:720]) { hull(){ rotate([0, 0, d]) translate([hubR + d * myScale, 0, 0]) sphere(d = ballDiam); rotate([0, 0, d]) translate([hubR + (d+1) * myScale, 0, 0]) sphere(d = ballDiam); } } }; difference() { translate([0, 0, -ballDiam * 0.7]) cylinder(h=ballDiam, r=28); spiral(); }
NH
nop head
Sun, Jun 14, 2015 12:55 AM

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the memory
because CGAL hates the massive implicit union of objects with lots of
vertices. It simply doesn't scale to high detail models. If you can
construct it with functions that generate lists to feed into polyhedron it
will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon jon@jonbondy.com wrote:

I can get this to work with F5, but not with F6: it just hangs for hours,
running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}


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

$fn = 50; for (d = [0:1:720]) hull() I think it will just take a very long time or consume all of the memory because CGAL hates the massive implicit union of objects with lots of vertices. It simply doesn't scale to high detail models. If you can construct it with functions that generate lists to feed into polyhedron it will be much faster. See the work kitwallace did with knots. A spiral is not too different. On 14 June 2015 at 01:35, jon <jon@jonbondy.com> wrote: > I can get this to work with F5, but not with F6: it just hangs for hours, > running full CPU. Any thoughts? > > > rch = 0.1; > ballDiam = 25.4 * 1/4 + rch; > $fn = 50; > > module spiral() { > myScale = 1/40; > hubR = 5; > for (d = [0:1:720]) { > hull(){ > rotate([0, 0, d]) > translate([hubR + d * myScale, 0, 0]) > sphere(d = ballDiam); > rotate([0, 0, d]) > translate([hubR + (d+1) * myScale, 0, 0]) > sphere(d = ballDiam); > > } > } > > }; > > difference() { > translate([0, 0, -ballDiam * 0.7]) > cylinder(h=ballDiam, r=28); > spiral(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
J
jon
Sun, Jun 14, 2015 1:04 AM

I've been programming for over 40 years.  Most of OpenSCAD is
more-or-less intuitive to me.  But "functions that generate lists to
feed into polyhedron" leaves me dazed.  Just like list comprehensions:
wonderful magic, but magic just the same.

Thanks

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the
memory because CGAL hates the massive implicit union of objects with
lots of vertices. It simply doesn't scale to high detail models. If
you can construct it with functions that generate lists to feed into
polyhedron it will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon <jon@jonbondy.com
mailto:jon@jonbondy.com> wrote:

 I can get this to work with F5, but not with F6: it just hangs for
 hours, running full CPU.  Any thoughts?


 rch = 0.1;
 ballDiam = 25.4 * 1/4 + rch;
 $fn = 50;

 module spiral() {
     myScale = 1/40;
     hubR = 5;
     for (d = [0:1:720]) {
         hull(){
             rotate([0, 0, d])
                 translate([hubR + d * myScale, 0, 0])
                     sphere(d = ballDiam);
             rotate([0, 0, d])
                 translate([hubR + (d+1) * myScale, 0, 0])
                     sphere(d = ballDiam);

             }
         }

     };

 difference() {
     translate([0, 0, -ballDiam * 0.7])
         cylinder(h=ballDiam, r=28);
     spiral();
     }

 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 http://www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15

I've been programming for over 40 years. Most of OpenSCAD is more-or-less intuitive to me. But "functions that generate lists to feed into polyhedron" leaves me dazed. Just like list comprehensions: wonderful magic, but magic just the same. Thanks On 6/13/2015 8:55 PM, nop head wrote: > $fn = 50; > for (d = [0:1:720]) hull() > > I think it will just take a very long time or consume all of the > memory because CGAL hates the massive implicit union of objects with > lots of vertices. It simply doesn't scale to high detail models. If > you can construct it with functions that generate lists to feed into > polyhedron it will be much faster. > > See the work kitwallace did with knots. A spiral is not too different. > > On 14 June 2015 at 01:35, jon <jon@jonbondy.com > <mailto:jon@jonbondy.com>> wrote: > > I can get this to work with F5, but not with F6: it just hangs for > hours, running full CPU. Any thoughts? > > > rch = 0.1; > ballDiam = 25.4 * 1/4 + rch; > $fn = 50; > > module spiral() { > myScale = 1/40; > hubR = 5; > for (d = [0:1:720]) { > hull(){ > rotate([0, 0, d]) > translate([hubR + d * myScale, 0, 0]) > sphere(d = ballDiam); > rotate([0, 0, d]) > translate([hubR + (d+1) * myScale, 0, 0]) > sphere(d = ballDiam); > > } > } > > }; > > difference() { > translate([0, 0, -ballDiam * 0.7]) > cylinder(h=ballDiam, r=28); > spiral(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > _______________________________________________ > 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 <http://www.avg.com> > Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15 >
CL
Chow Loong Jin
Sun, Jun 14, 2015 6:24 AM

On Sat, Jun 13, 2015 at 09:04:13PM -0400, jon wrote:

I've been programming for over 40 years.  Most of OpenSCAD is more-or-less
intuitive to me.  But "functions that generate lists to feed into
polyhedron" leaves me dazed.  Just like list comprehensions: wonderful
magic, but magic just the same.

List comprehensions aren't a new thing though:
https://en.wikipedia.org/wiki/List_comprehension

--
Kind regards,
Loong Jin

On Sat, Jun 13, 2015 at 09:04:13PM -0400, jon wrote: > I've been programming for over 40 years. Most of OpenSCAD is more-or-less > intuitive to me. But "functions that generate lists to feed into > polyhedron" leaves me dazed. Just like list comprehensions: wonderful > magic, but magic just the same. List comprehensions aren't a new thing though: https://en.wikipedia.org/wiki/List_comprehension -- Kind regards, Loong Jin
J
jon
Sun, Jun 14, 2015 11:41 AM

I found and modified kit wallace's knot code (which is based on some of
your code).  Once I understood that the function at the top controlled
the entire object, it was indeed simple.  That is, the two of you made
it simple for me!  Not sure how to eliminate the requirement that the
tube be closed, though.

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the
memory because CGAL hates the massive implicit union of objects with
lots of vertices. It simply doesn't scale to high detail models. If
you can construct it with functions that generate lists to feed into
polyhedron it will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon <jon@jonbondy.com
mailto:jon@jonbondy.com> wrote:

 I can get this to work with F5, but not with F6: it just hangs for
 hours, running full CPU.  Any thoughts?


 rch = 0.1;
 ballDiam = 25.4 * 1/4 + rch;
 $fn = 50;

 module spiral() {
     myScale = 1/40;
     hubR = 5;
     for (d = [0:1:720]) {
         hull(){
             rotate([0, 0, d])
                 translate([hubR + d * myScale, 0, 0])
                     sphere(d = ballDiam);
             rotate([0, 0, d])
                 translate([hubR + (d+1) * myScale, 0, 0])
                     sphere(d = ballDiam);

             }
         }

     };

 difference() {
     translate([0, 0, -ballDiam * 0.7])
         cylinder(h=ballDiam, r=28);
     spiral();
     }

 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 http://www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15

I found and modified kit wallace's knot code (which is based on some of your code). Once I understood that the function at the top controlled the entire object, it was indeed simple. That is, the two of you made it simple for me! Not sure how to eliminate the requirement that the tube be closed, though. On 6/13/2015 8:55 PM, nop head wrote: > $fn = 50; > for (d = [0:1:720]) hull() > > I think it will just take a very long time or consume all of the > memory because CGAL hates the massive implicit union of objects with > lots of vertices. It simply doesn't scale to high detail models. If > you can construct it with functions that generate lists to feed into > polyhedron it will be much faster. > > See the work kitwallace did with knots. A spiral is not too different. > > On 14 June 2015 at 01:35, jon <jon@jonbondy.com > <mailto:jon@jonbondy.com>> wrote: > > I can get this to work with F5, but not with F6: it just hangs for > hours, running full CPU. Any thoughts? > > > rch = 0.1; > ballDiam = 25.4 * 1/4 + rch; > $fn = 50; > > module spiral() { > myScale = 1/40; > hubR = 5; > for (d = [0:1:720]) { > hull(){ > rotate([0, 0, d]) > translate([hubR + d * myScale, 0, 0]) > sphere(d = ballDiam); > rotate([0, 0, d]) > translate([hubR + (d+1) * myScale, 0, 0]) > sphere(d = ballDiam); > > } > } > > }; > > difference() { > translate([0, 0, -ballDiam * 0.7]) > cylinder(h=ballDiam, r=28); > spiral(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > _______________________________________________ > 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 <http://www.avg.com> > Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15 >
NH
nop head
Sun, Jun 14, 2015 12:31 PM

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
myScale = 1/40;
hubR = 5;

function f(a,b,t) =  // spiral
[ (a + t * b) * cos(t),
(a + t * b) * sin(t),
0
];

$fn = 50;

function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1  ] ];

function m_rotate(v) =  [ [1,  0,        0,        0],
[0,  cos(v.x),  sin(v.x), 0],
[0, -sin(v.x),  cos(v.x), 0],
[0,  0,        0,        1] ]
* [ [ cos(v.y), 0,  -sin(v.y), 0],
[0,        1,  0,        0],
[ sin(v.y), 0,  cos(v.y), 0],
[0,        0,  0,        1] ]
* [ [ cos(v.z),  sin(v.z), 0, 0],
[-sin(v.z),  cos(v.z), 0, 0],
[ 0,        0,        1, 0],
[ 0,        0,        0, 1] ];

function vec3(v) = [v.x, v.y, v.z];
function transform(v, m)  = vec3([v.x, v.y, v.z, 1] * m);

function orientate(position, normal) = m_rotate([0,
atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0])
* m_rotate([0, 0, atan2(normal[1], normal[0])])
* m_translate(position);

function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r *
cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ;

function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)],
path_points(a, b, step, t + step)) : [] ;

function transform_points(list, matrix, i = 0) = i < len(list) ? concat([
transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : [];

function tube_points(profile, path, i = 0) = i < len(path) - 1
? concat(transform_points(profile,
orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path,
i + 1))
: transform_points(profile,
orientate(path[i], (path[i] - path[i - 1])/ 2)) ;

function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s *
facets + i,
s *
facets + (i + 1) % facets,
((s +

  1. % segs) * facets + (i + 1) % facets,
    ((s +
  2. % segs) * facets + i]],

tube_faces(segs, facets, s, i + 1)) : [];

function path_faces(segs, facets, i = 0) = i < segs - 1 ?
concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : [];

function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets *
segment, cap(facets, segment, i + 1)) : [];

circle_points = circle_points(ballDiam / 2);
facets = len(circle_points);

path_points = path_points(hubR, myScale, 1);
segments = len(path_points);

tube_points = tube_points(circle_points, path_points);
path_faces = path_faces(segments, facets);

union() {
translate(path_points[0])
sphere(ballDiam / 2);

polyhedron(points = tube_points, faces = concat([cap(facets)],

path_faces, [cap(facets, segments - 1)]));

translate(path_points[segments - 1])
    sphere(ballDiam / 2);

}

On 14 June 2015 at 12:41, jon jon@jonbondy.com wrote:

I found and modified kit wallace's knot code (which is based on some of
your code).  Once I understood that the function at the top controlled the
entire object, it was indeed simple.  That is, the two of you made it
simple for me!  Not sure how to eliminate the requirement that the tube be
closed, though.

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the memory
because CGAL hates the massive implicit union of objects with lots of
vertices. It simply doesn't scale to high detail models. If you can
construct it with functions that generate lists to feed into polyhedron it
will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon jon@jonbondy.com wrote:

I can get this to work with F5, but not with F6: it just hangs for hours,
running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15


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

rch = 0.1; ballDiam = 25.4 * 1/4 + rch; myScale = 1/40; hubR = 5; function f(a,b,t) = // spiral [ (a + t * b) * cos(t), (a + t * b) * sin(t), 0 ]; $fn = 50; function m_translate(v) = [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [v.x, v.y, v.z, 1 ] ]; function m_rotate(v) = [ [1, 0, 0, 0], [0, cos(v.x), sin(v.x), 0], [0, -sin(v.x), cos(v.x), 0], [0, 0, 0, 1] ] * [ [ cos(v.y), 0, -sin(v.y), 0], [0, 1, 0, 0], [ sin(v.y), 0, cos(v.y), 0], [0, 0, 0, 1] ] * [ [ cos(v.z), sin(v.z), 0, 0], [-sin(v.z), cos(v.z), 0, 0], [ 0, 0, 1, 0], [ 0, 0, 0, 1] ]; function vec3(v) = [v.x, v.y, v.z]; function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m); function orientate(position, normal) = m_rotate([0, atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0]) * m_rotate([0, 0, atan2(normal[1], normal[0])]) * m_translate(position); function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r * cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ; function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)], path_points(a, b, step, t + step)) : [] ; function transform_points(list, matrix, i = 0) = i < len(list) ? concat([ transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : []; function tube_points(profile, path, i = 0) = i < len(path) - 1 ? concat(transform_points(profile, orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path, i + 1)) : transform_points(profile, orientate(path[i], (path[i] - path[i - 1])/ 2)) ; function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s * facets + i, s * facets + (i + 1) % facets, ((s + 1) % segs) * facets + (i + 1) % facets, ((s + 1) % segs) * facets + i]], tube_faces(segs, facets, s, i + 1)) : []; function path_faces(segs, facets, i = 0) = i < segs - 1 ? concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : []; function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets * segment, cap(facets, segment, i + 1)) : []; circle_points = circle_points(ballDiam / 2); facets = len(circle_points); path_points = path_points(hubR, myScale, 1); segments = len(path_points); tube_points = tube_points(circle_points, path_points); path_faces = path_faces(segments, facets); union() { translate(path_points[0]) sphere(ballDiam / 2); polyhedron(points = tube_points, faces = concat([cap(facets)], path_faces, [cap(facets, segments - 1)])); translate(path_points[segments - 1]) sphere(ballDiam / 2); } On 14 June 2015 at 12:41, jon <jon@jonbondy.com> wrote: > I found and modified kit wallace's knot code (which is based on some of > your code). Once I understood that the function at the top controlled the > entire object, it was indeed simple. That is, the two of you made it > simple for me! Not sure how to eliminate the requirement that the tube be > closed, though. > > On 6/13/2015 8:55 PM, nop head wrote: > > $fn = 50; > for (d = [0:1:720]) hull() > > I think it will just take a very long time or consume all of the memory > because CGAL hates the massive implicit union of objects with lots of > vertices. It simply doesn't scale to high detail models. If you can > construct it with functions that generate lists to feed into polyhedron it > will be much faster. > > See the work kitwallace did with knots. A spiral is not too different. > > On 14 June 2015 at 01:35, jon <jon@jonbondy.com> wrote: > >> I can get this to work with F5, but not with F6: it just hangs for hours, >> running full CPU. Any thoughts? >> >> >> rch = 0.1; >> ballDiam = 25.4 * 1/4 + rch; >> $fn = 50; >> >> module spiral() { >> myScale = 1/40; >> hubR = 5; >> for (d = [0:1:720]) { >> hull(){ >> rotate([0, 0, d]) >> translate([hubR + d * myScale, 0, 0]) >> sphere(d = ballDiam); >> rotate([0, 0, d]) >> translate([hubR + (d+1) * myScale, 0, 0]) >> sphere(d = ballDiam); >> >> } >> } >> >> }; >> >> difference() { >> translate([0, 0, -ballDiam * 0.7]) >> cylinder(h=ballDiam, r=28); >> spiral(); >> } >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > > > _______________________________________________ > OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15 > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
J
jon
Sun, Jun 14, 2015 1:54 PM

Thank you very much.  You are very generous with your time.

Jon

On 6/14/2015 8:31 AM, nop head wrote:

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
myScale = 1/40;
hubR = 5;

function f(a,b,t) =  // spiral
[ (a + t * b) * cos(t),
(a + t * b) * sin(t),
0
];

$fn = 50;

function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1  ] ];

function m_rotate(v) =  [ [1,  0,        0,        0],
[0,  cos(v.x),  sin(v.x), 0],
[0, -sin(v.x),  cos(v.x), 0],
[0,  0,        0,        1] ]
* [ [ cos(v.y), 0,  -sin(v.y), 0],
[0,        1,  0,        0],
[ sin(v.y), 0,  cos(v.y), 0],
[0,        0,  0,        1] ]
* [ [ cos(v.z),  sin(v.z), 0, 0],
[-sin(v.z),  cos(v.z), 0, 0],
[ 0,        0,        1, 0],
[ 0,        0,        0, 1] ];

function vec3(v) = [v.x, v.y, v.z];
function transform(v, m)  = vec3([v.x, v.y, v.z, 1] * m);

function orientate(position, normal) = m_rotate([0,
atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0])
* m_rotate([0, 0, atan2(normal[1], normal[0])])
* m_translate(position);

function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a),
r * cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ;

function path_points(a, b, step, t = 0) = t <= 720 ?
concat([f(a,b,t)], path_points(a, b, step, t + step)) : [] ;

function transform_points(list, matrix, i = 0) = i < len(list) ?
concat([ transform(list[i], matrix) ], transform_points(list, matrix,
i + 1)) : [];

function tube_points(profile, path, i = 0) = i < len(path) - 1
? concat(transform_points(profile,
orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile,
path, i + 1))
: transform_points(profile,
orientate(path[i], (path[i] - path[i - 1])/ 2)) ;

function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s

  • facets + i,
    s * facets + (i + 1) % facets,
    ((s + 1) % segs) * facets + (i + 1) % facets,
    ((s + 1) % segs) * facets + i]],
    tube_faces(segs, facets, s, i + 1)) : [];

function path_faces(segs, facets, i = 0) = i < segs - 1 ?
concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : [];

function cap(facets, segment = 0, i = 0) = i < facets ? concat(i +
facets * segment, cap(facets, segment, i + 1)) : [];

circle_points = circle_points(ballDiam / 2);
facets = len(circle_points);

path_points = path_points(hubR, myScale, 1);
segments = len(path_points);

tube_points = tube_points(circle_points, path_points);
path_faces = path_faces(segments, facets);

union() {
translate(path_points[0])
sphere(ballDiam / 2);

 polyhedron(points = tube_points, faces = concat([cap(facets)], 

path_faces, [cap(facets, segments - 1)]));

 translate(path_points[segments - 1])
     sphere(ballDiam / 2);

}

On 14 June 2015 at 12:41, jon <jon@jonbondy.com
mailto:jon@jonbondy.com> wrote:

 I found and modified kit wallace's knot code (which is based on
 some of your code).  Once I understood that the function at the
 top controlled the entire object, it was indeed simple.  That is,
 the two of you made it simple for me! Not sure how to eliminate
 the requirement that the tube be closed, though.

 On 6/13/2015 8:55 PM, nop head wrote:
 $fn = 50;
 for (d = [0:1:720]) hull()

 I think it will just take a very long time or consume all of the
 memory because CGAL hates the massive implicit union of objects
 with lots of vertices. It simply doesn't scale to high detail
 models. If you can construct it with functions that generate
 lists to feed into polyhedron it will be much faster.

 See the work kitwallace did with knots. A spiral is not too
 different.

 On 14 June 2015 at 01:35, jon <jon@jonbondy.com
 <mailto:jon@jonbondy.com>> wrote:

     I can get this to work with F5, but not with F6: it just
     hangs for hours, running full CPU.  Any thoughts?


     rch = 0.1;
     ballDiam = 25.4 * 1/4 + rch;
     $fn = 50;

     module spiral() {
         myScale = 1/40;
         hubR = 5;
         for (d = [0:1:720]) {
             hull(){
                 rotate([0, 0, d])
                     translate([hubR + d * myScale, 0, 0])
                         sphere(d = ballDiam);
                 rotate([0, 0, d])
                     translate([hubR + (d+1) * myScale, 0, 0])
                         sphere(d = ballDiam);

                 }
             }

         };

     difference() {
         translate([0, 0, -ballDiam * 0.7])
             cylinder(h=ballDiam, r=28);
         spiral();
         }

     _______________________________________________
     OpenSCAD mailing list
     Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
     http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org  <mailto: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 <http://www.avg.com>
 Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date:
 06/13/15
 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 http://www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15

Thank you very much. You are very generous with your time. Jon On 6/14/2015 8:31 AM, nop head wrote: > rch = 0.1; > ballDiam = 25.4 * 1/4 + rch; > myScale = 1/40; > hubR = 5; > > function f(a,b,t) = // spiral > [ (a + t * b) * cos(t), > (a + t * b) * sin(t), > 0 > ]; > > $fn = 50; > > function m_translate(v) = [ [1, 0, 0, 0], > [0, 1, 0, 0], > [0, 0, 1, 0], > [v.x, v.y, v.z, 1 ] ]; > > function m_rotate(v) = [ [1, 0, 0, 0], > [0, cos(v.x), sin(v.x), 0], > [0, -sin(v.x), cos(v.x), 0], > [0, 0, 0, 1] ] > * [ [ cos(v.y), 0, -sin(v.y), 0], > [0, 1, 0, 0], > [ sin(v.y), 0, cos(v.y), 0], > [0, 0, 0, 1] ] > * [ [ cos(v.z), sin(v.z), 0, 0], > [-sin(v.z), cos(v.z), 0, 0], > [ 0, 0, 1, 0], > [ 0, 0, 0, 1] ]; > > function vec3(v) = [v.x, v.y, v.z]; > function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m); > > function orientate(position, normal) = m_rotate([0, > atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0]) > * m_rotate([0, 0, atan2(normal[1], normal[0])]) > * m_translate(position); > > function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), > r * cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ; > > function path_points(a, b, step, t = 0) = t <= 720 ? > concat([f(a,b,t)], path_points(a, b, step, t + step)) : [] ; > > function transform_points(list, matrix, i = 0) = i < len(list) ? > concat([ transform(list[i], matrix) ], transform_points(list, matrix, > i + 1)) : []; > > function tube_points(profile, path, i = 0) = i < len(path) - 1 > ? concat(transform_points(profile, > orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, > path, i + 1)) > : transform_points(profile, > orientate(path[i], (path[i] - path[i - 1])/ 2)) ; > > function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s > * facets + i, > s * facets + (i + 1) % facets, > ((s + 1) % segs) * facets + (i + 1) % facets, > ((s + 1) % segs) * facets + i]], > tube_faces(segs, facets, s, i + 1)) : []; > > function path_faces(segs, facets, i = 0) = i < segs - 1 ? > concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : []; > > function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + > facets * segment, cap(facets, segment, i + 1)) : []; > > circle_points = circle_points(ballDiam / 2); > facets = len(circle_points); > > path_points = path_points(hubR, myScale, 1); > segments = len(path_points); > > tube_points = tube_points(circle_points, path_points); > path_faces = path_faces(segments, facets); > > union() { > translate(path_points[0]) > sphere(ballDiam / 2); > > polyhedron(points = tube_points, faces = concat([cap(facets)], > path_faces, [cap(facets, segments - 1)])); > > translate(path_points[segments - 1]) > sphere(ballDiam / 2); > } > > > On 14 June 2015 at 12:41, jon <jon@jonbondy.com > <mailto:jon@jonbondy.com>> wrote: > > I found and modified kit wallace's knot code (which is based on > some of your code). Once I understood that the function at the > top controlled the entire object, it was indeed simple. That is, > the two of you made it simple for me! Not sure how to eliminate > the requirement that the tube be closed, though. > > On 6/13/2015 8:55 PM, nop head wrote: >> $fn = 50; >> for (d = [0:1:720]) hull() >> >> I think it will just take a very long time or consume all of the >> memory because CGAL hates the massive implicit union of objects >> with lots of vertices. It simply doesn't scale to high detail >> models. If you can construct it with functions that generate >> lists to feed into polyhedron it will be much faster. >> >> See the work kitwallace did with knots. A spiral is not too >> different. >> >> On 14 June 2015 at 01:35, jon <jon@jonbondy.com >> <mailto:jon@jonbondy.com>> wrote: >> >> I can get this to work with F5, but not with F6: it just >> hangs for hours, running full CPU. Any thoughts? >> >> >> rch = 0.1; >> ballDiam = 25.4 * 1/4 + rch; >> $fn = 50; >> >> module spiral() { >> myScale = 1/40; >> hubR = 5; >> for (d = [0:1:720]) { >> hull(){ >> rotate([0, 0, d]) >> translate([hubR + d * myScale, 0, 0]) >> sphere(d = ballDiam); >> rotate([0, 0, d]) >> translate([hubR + (d+1) * myScale, 0, 0]) >> sphere(d = ballDiam); >> >> } >> } >> >> }; >> >> difference() { >> translate([0, 0, -ballDiam * 0.7]) >> cylinder(h=ballDiam, r=28); >> spiral(); >> } >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org <mailto: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 <http://www.avg.com> >> Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: >> 06/13/15 >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > _______________________________________________ > 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 <http://www.avg.com> > Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15 >
NH
nop head
Sun, Jun 14, 2015 2:07 PM

Unfortunately F6 fails on my system but it works in 2 minutes if I remove
the spheres at the end points.

Looks like a bug in OpenScad triggered by unioning nearly coincident faces.

On 14 June 2015 at 14:54, jon jon@jonbondy.com wrote:

Thank you very much.  You are very generous with your time.

Jon

On 6/14/2015 8:31 AM, nop head wrote:

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
myScale = 1/40;
hubR = 5;

function f(a,b,t) =  // spiral
[ (a + t * b) * cos(t),
(a + t * b) * sin(t),
0
];

$fn = 50;

function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1  ] ];

function m_rotate(v) =  [ [1,  0,        0,        0],
[0,  cos(v.x),  sin(v.x), 0],
[0, -sin(v.x),  cos(v.x), 0],
[0,  0,        0,        1] ]
* [ [ cos(v.y), 0,  -sin(v.y), 0],
[0,        1,  0,        0],
[ sin(v.y), 0,  cos(v.y), 0],
[0,        0,  0,        1] ]
* [ [ cos(v.z),  sin(v.z), 0, 0],
[-sin(v.z),  cos(v.z), 0, 0],
[ 0,        0,        1, 0],
[ 0,        0,        0, 1] ];

function vec3(v) = [v.x, v.y, v.z];
function transform(v, m)  = vec3([v.x, v.y, v.z, 1] * m);

function orientate(position, normal) = m_rotate([0,
atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0])
* m_rotate([0, 0, atan2(normal[1], normal[0])])
* m_translate(position);

function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r *
cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ;

function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)],
path_points(a, b, step, t + step)) : [] ;

function transform_points(list, matrix, i = 0) = i < len(list) ? concat([
transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : [];

function tube_points(profile, path, i = 0) = i < len(path) - 1
? concat(transform_points(profile,
orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path,
i + 1))
: transform_points(profile,
orientate(path[i], (path[i] - path[i - 1])/ 2)) ;

function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s *
facets + i,
s *
facets + (i + 1) % facets,
((s +

  1. % segs) * facets + (i + 1) % facets,
    ((s +
  2. % segs) * facets + i]],

tube_faces(segs, facets, s, i + 1)) : [];

function path_faces(segs, facets, i = 0) = i < segs - 1 ?
concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : [];

function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets

  • segment, cap(facets, segment, i + 1)) : [];

circle_points = circle_points(ballDiam / 2);
facets = len(circle_points);

path_points = path_points(hubR, myScale, 1);
segments = len(path_points);

tube_points = tube_points(circle_points, path_points);
path_faces = path_faces(segments, facets);

union() {
translate(path_points[0])
sphere(ballDiam / 2);

 polyhedron(points = tube_points, faces = concat([cap(facets)],

path_faces, [cap(facets, segments - 1)]));

 translate(path_points[segments - 1])
     sphere(ballDiam / 2);

}

On 14 June 2015 at 12:41, jon jon@jonbondy.com wrote:

I found and modified kit wallace's knot code (which is based on some of
your code).  Once I understood that the function at the top controlled the
entire object, it was indeed simple.  That is, the two of you made it
simple for me!  Not sure how to eliminate the requirement that the tube be
closed, though.

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the memory
because CGAL hates the massive implicit union of objects with lots of
vertices. It simply doesn't scale to high detail models. If you can
construct it with functions that generate lists to feed into polyhedron it
will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon jon@jonbondy.com wrote:

I can get this to work with F5, but not with F6: it just hangs for
hours, running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15


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

Unfortunately F6 fails on my system but it works in 2 minutes if I remove the spheres at the end points. Looks like a bug in OpenScad triggered by unioning nearly coincident faces. On 14 June 2015 at 14:54, jon <jon@jonbondy.com> wrote: > Thank you very much. You are very generous with your time. > > Jon > > > On 6/14/2015 8:31 AM, nop head wrote: > > rch = 0.1; > ballDiam = 25.4 * 1/4 + rch; > myScale = 1/40; > hubR = 5; > > function f(a,b,t) = // spiral > [ (a + t * b) * cos(t), > (a + t * b) * sin(t), > 0 > ]; > > $fn = 50; > > function m_translate(v) = [ [1, 0, 0, 0], > [0, 1, 0, 0], > [0, 0, 1, 0], > [v.x, v.y, v.z, 1 ] ]; > > function m_rotate(v) = [ [1, 0, 0, 0], > [0, cos(v.x), sin(v.x), 0], > [0, -sin(v.x), cos(v.x), 0], > [0, 0, 0, 1] ] > * [ [ cos(v.y), 0, -sin(v.y), 0], > [0, 1, 0, 0], > [ sin(v.y), 0, cos(v.y), 0], > [0, 0, 0, 1] ] > * [ [ cos(v.z), sin(v.z), 0, 0], > [-sin(v.z), cos(v.z), 0, 0], > [ 0, 0, 1, 0], > [ 0, 0, 0, 1] ]; > > function vec3(v) = [v.x, v.y, v.z]; > function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m); > > function orientate(position, normal) = m_rotate([0, > atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0]) > * m_rotate([0, 0, atan2(normal[1], normal[0])]) > * m_translate(position); > > function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r * > cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ; > > function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)], > path_points(a, b, step, t + step)) : [] ; > > function transform_points(list, matrix, i = 0) = i < len(list) ? concat([ > transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : []; > > function tube_points(profile, path, i = 0) = i < len(path) - 1 > ? concat(transform_points(profile, > orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path, > i + 1)) > : transform_points(profile, > orientate(path[i], (path[i] - path[i - 1])/ 2)) ; > > function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s * > facets + i, > s * > facets + (i + 1) % facets, > ((s + > 1) % segs) * facets + (i + 1) % facets, > ((s + > 1) % segs) * facets + i]], > > tube_faces(segs, facets, s, i + 1)) : []; > > function path_faces(segs, facets, i = 0) = i < segs - 1 ? > concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : []; > > function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets > * segment, cap(facets, segment, i + 1)) : []; > > circle_points = circle_points(ballDiam / 2); > facets = len(circle_points); > > path_points = path_points(hubR, myScale, 1); > segments = len(path_points); > > tube_points = tube_points(circle_points, path_points); > path_faces = path_faces(segments, facets); > > union() { > translate(path_points[0]) > sphere(ballDiam / 2); > > polyhedron(points = tube_points, faces = concat([cap(facets)], > path_faces, [cap(facets, segments - 1)])); > > translate(path_points[segments - 1]) > sphere(ballDiam / 2); > } > > > On 14 June 2015 at 12:41, jon <jon@jonbondy.com> wrote: > >> I found and modified kit wallace's knot code (which is based on some of >> your code). Once I understood that the function at the top controlled the >> entire object, it was indeed simple. That is, the two of you made it >> simple for me! Not sure how to eliminate the requirement that the tube be >> closed, though. >> >> On 6/13/2015 8:55 PM, nop head wrote: >> >> $fn = 50; >> for (d = [0:1:720]) hull() >> >> I think it will just take a very long time or consume all of the memory >> because CGAL hates the massive implicit union of objects with lots of >> vertices. It simply doesn't scale to high detail models. If you can >> construct it with functions that generate lists to feed into polyhedron it >> will be much faster. >> >> See the work kitwallace did with knots. A spiral is not too different. >> >> On 14 June 2015 at 01:35, jon <jon@jonbondy.com> wrote: >> >>> I can get this to work with F5, but not with F6: it just hangs for >>> hours, running full CPU. Any thoughts? >>> >>> >>> rch = 0.1; >>> ballDiam = 25.4 * 1/4 + rch; >>> $fn = 50; >>> >>> module spiral() { >>> myScale = 1/40; >>> hubR = 5; >>> for (d = [0:1:720]) { >>> hull(){ >>> rotate([0, 0, d]) >>> translate([hubR + d * myScale, 0, 0]) >>> sphere(d = ballDiam); >>> rotate([0, 0, d]) >>> translate([hubR + (d+1) * myScale, 0, 0]) >>> sphere(d = ballDiam); >>> >>> } >>> } >>> >>> }; >>> >>> difference() { >>> translate([0, 0, -ballDiam * 0.7]) >>> cylinder(h=ballDiam, r=28); >>> spiral(); >>> } >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> >> >> >> _______________________________________________ >> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> >> No virus found in this message. >> Checked by AVG - www.avg.com >> Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: 06/13/15 >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > > _______________________________________________ > OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15 > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Sun, Jun 14, 2015 2:17 PM

PolySet has nonplanar faces. Attempting alternate construction

ERROR: Alternate construction failed. CGAL error in CGAL_Nef_polyhedron3():
CGAL ERROR: assertion violation! Expr: e->incident_sface() !=
SFace_const_handle() File:
/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

On 14 June 2015 at 15:07, nop head nop.head@gmail.com wrote:

Unfortunately F6 fails on my system but it works in 2 minutes if I remove
the spheres at the end points.

Looks like a bug in OpenScad triggered by unioning nearly coincident faces.

On 14 June 2015 at 14:54, jon jon@jonbondy.com wrote:

Thank you very much.  You are very generous with your time.

Jon

On 6/14/2015 8:31 AM, nop head wrote:

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
myScale = 1/40;
hubR = 5;

function f(a,b,t) =  // spiral
[ (a + t * b) * cos(t),
(a + t * b) * sin(t),
0
];

$fn = 50;

function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1  ] ];

function m_rotate(v) =  [ [1,  0,        0,        0],
[0,  cos(v.x),  sin(v.x), 0],
[0, -sin(v.x),  cos(v.x), 0],
[0,  0,        0,        1] ]
* [ [ cos(v.y), 0,  -sin(v.y), 0],
[0,        1,  0,        0],
[ sin(v.y), 0,  cos(v.y), 0],
[0,        0,  0,        1] ]
* [ [ cos(v.z),  sin(v.z), 0, 0],
[-sin(v.z),  cos(v.z), 0, 0],
[ 0,        0,        1, 0],
[ 0,        0,        0, 1] ];

function vec3(v) = [v.x, v.y, v.z];
function transform(v, m)  = vec3([v.x, v.y, v.z, 1] * m);

function orientate(position, normal) = m_rotate([0,
atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0])
* m_rotate([0, 0, atan2(normal[1], normal[0])])
* m_translate(position);

function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r *
cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ;

function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)],
path_points(a, b, step, t + step)) : [] ;

function transform_points(list, matrix, i = 0) = i < len(list) ? concat([
transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : [];

function tube_points(profile, path, i = 0) = i < len(path) - 1
? concat(transform_points(profile,
orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path,
i + 1))
: transform_points(profile,
orientate(path[i], (path[i] - path[i - 1])/ 2)) ;

function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s *
facets + i,
s *
facets + (i + 1) % facets,
((s +

  1. % segs) * facets + (i + 1) % facets,
    ((s +
  2. % segs) * facets + i]],

tube_faces(segs, facets, s, i + 1)) : [];

function path_faces(segs, facets, i = 0) = i < segs - 1 ?
concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : [];

function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets

  • segment, cap(facets, segment, i + 1)) : [];

circle_points = circle_points(ballDiam / 2);
facets = len(circle_points);

path_points = path_points(hubR, myScale, 1);
segments = len(path_points);

tube_points = tube_points(circle_points, path_points);
path_faces = path_faces(segments, facets);

union() {
translate(path_points[0])
sphere(ballDiam / 2);

 polyhedron(points = tube_points, faces = concat([cap(facets)],

path_faces, [cap(facets, segments - 1)]));

 translate(path_points[segments - 1])
     sphere(ballDiam / 2);

}

On 14 June 2015 at 12:41, jon jon@jonbondy.com wrote:

I found and modified kit wallace's knot code (which is based on some of
your code).  Once I understood that the function at the top controlled the
entire object, it was indeed simple.  That is, the two of you made it
simple for me!  Not sure how to eliminate the requirement that the tube be
closed, though.

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the memory
because CGAL hates the massive implicit union of objects with lots of
vertices. It simply doesn't scale to high detail models. If you can
construct it with functions that generate lists to feed into polyhedron it
will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon jon@jonbondy.com wrote:

I can get this to work with F5, but not with F6: it just hangs for
hours, running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date:
06/13/15


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15


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

PolySet has nonplanar faces. Attempting alternate construction ERROR: Alternate construction failed. CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326 On 14 June 2015 at 15:07, nop head <nop.head@gmail.com> wrote: > Unfortunately F6 fails on my system but it works in 2 minutes if I remove > the spheres at the end points. > > Looks like a bug in OpenScad triggered by unioning nearly coincident faces. > > On 14 June 2015 at 14:54, jon <jon@jonbondy.com> wrote: > >> Thank you very much. You are very generous with your time. >> >> Jon >> >> >> On 6/14/2015 8:31 AM, nop head wrote: >> >> rch = 0.1; >> ballDiam = 25.4 * 1/4 + rch; >> myScale = 1/40; >> hubR = 5; >> >> function f(a,b,t) = // spiral >> [ (a + t * b) * cos(t), >> (a + t * b) * sin(t), >> 0 >> ]; >> >> $fn = 50; >> >> function m_translate(v) = [ [1, 0, 0, 0], >> [0, 1, 0, 0], >> [0, 0, 1, 0], >> [v.x, v.y, v.z, 1 ] ]; >> >> function m_rotate(v) = [ [1, 0, 0, 0], >> [0, cos(v.x), sin(v.x), 0], >> [0, -sin(v.x), cos(v.x), 0], >> [0, 0, 0, 1] ] >> * [ [ cos(v.y), 0, -sin(v.y), 0], >> [0, 1, 0, 0], >> [ sin(v.y), 0, cos(v.y), 0], >> [0, 0, 0, 1] ] >> * [ [ cos(v.z), sin(v.z), 0, 0], >> [-sin(v.z), cos(v.z), 0, 0], >> [ 0, 0, 1, 0], >> [ 0, 0, 0, 1] ]; >> >> function vec3(v) = [v.x, v.y, v.z]; >> function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m); >> >> function orientate(position, normal) = m_rotate([0, >> atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0]) >> * m_rotate([0, 0, atan2(normal[1], normal[0])]) >> * m_translate(position); >> >> function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r * >> cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ; >> >> function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)], >> path_points(a, b, step, t + step)) : [] ; >> >> function transform_points(list, matrix, i = 0) = i < len(list) ? concat([ >> transform(list[i], matrix) ], transform_points(list, matrix, i + 1)) : []; >> >> function tube_points(profile, path, i = 0) = i < len(path) - 1 >> ? concat(transform_points(profile, >> orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path, >> i + 1)) >> : transform_points(profile, >> orientate(path[i], (path[i] - path[i - 1])/ 2)) ; >> >> function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s * >> facets + i, >> s * >> facets + (i + 1) % facets, >> ((s + >> 1) % segs) * facets + (i + 1) % facets, >> ((s + >> 1) % segs) * facets + i]], >> >> tube_faces(segs, facets, s, i + 1)) : []; >> >> function path_faces(segs, facets, i = 0) = i < segs - 1 ? >> concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : []; >> >> function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + facets >> * segment, cap(facets, segment, i + 1)) : []; >> >> circle_points = circle_points(ballDiam / 2); >> facets = len(circle_points); >> >> path_points = path_points(hubR, myScale, 1); >> segments = len(path_points); >> >> tube_points = tube_points(circle_points, path_points); >> path_faces = path_faces(segments, facets); >> >> union() { >> translate(path_points[0]) >> sphere(ballDiam / 2); >> >> polyhedron(points = tube_points, faces = concat([cap(facets)], >> path_faces, [cap(facets, segments - 1)])); >> >> translate(path_points[segments - 1]) >> sphere(ballDiam / 2); >> } >> >> >> On 14 June 2015 at 12:41, jon <jon@jonbondy.com> wrote: >> >>> I found and modified kit wallace's knot code (which is based on some of >>> your code). Once I understood that the function at the top controlled the >>> entire object, it was indeed simple. That is, the two of you made it >>> simple for me! Not sure how to eliminate the requirement that the tube be >>> closed, though. >>> >>> On 6/13/2015 8:55 PM, nop head wrote: >>> >>> $fn = 50; >>> for (d = [0:1:720]) hull() >>> >>> I think it will just take a very long time or consume all of the memory >>> because CGAL hates the massive implicit union of objects with lots of >>> vertices. It simply doesn't scale to high detail models. If you can >>> construct it with functions that generate lists to feed into polyhedron it >>> will be much faster. >>> >>> See the work kitwallace did with knots. A spiral is not too different. >>> >>> On 14 June 2015 at 01:35, jon <jon@jonbondy.com> wrote: >>> >>>> I can get this to work with F5, but not with F6: it just hangs for >>>> hours, running full CPU. Any thoughts? >>>> >>>> >>>> rch = 0.1; >>>> ballDiam = 25.4 * 1/4 + rch; >>>> $fn = 50; >>>> >>>> module spiral() { >>>> myScale = 1/40; >>>> hubR = 5; >>>> for (d = [0:1:720]) { >>>> hull(){ >>>> rotate([0, 0, d]) >>>> translate([hubR + d * myScale, 0, 0]) >>>> sphere(d = ballDiam); >>>> rotate([0, 0, d]) >>>> translate([hubR + (d+1) * myScale, 0, 0]) >>>> sphere(d = ballDiam); >>>> >>>> } >>>> } >>>> >>>> }; >>>> >>>> difference() { >>>> translate([0, 0, -ballDiam * 0.7]) >>>> cylinder(h=ballDiam, r=28); >>>> spiral(); >>>> } >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>> >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >>> >>> No virus found in this message. >>> Checked by AVG - www.avg.com >>> Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: >>> 06/13/15 >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >> >> >> _______________________________________________ >> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> >> No virus found in this message. >> Checked by AVG - www.avg.com >> Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: 06/14/15 >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
NH
nop head
Sun, Jun 14, 2015 2:41 PM

Actually it was caused by the winding order of one of the end caps being
wrong. This fixes it: -

function cap(facets, segment = 0, i = 0) = i < facets ? concat(segment ?
facets * segment + i : facets - 1 - i, cap(facets, segment, i + 1)) : [];

Also the sphere facets can be aligned with the tube by adding a rotation:

translate(path_points[0])
    rotate([0, 180 / $fn, 0]) sphere(ballDiam / 2);

On 14 June 2015 at 15:17, nop head nop.head@gmail.com wrote:

PolySet has nonplanar faces. Attempting alternate construction

ERROR: Alternate construction failed. CGAL error in
CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr:
e->incident_sface() != SFace_const_handle() File:
/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

On 14 June 2015 at 15:07, nop head nop.head@gmail.com wrote:

Unfortunately F6 fails on my system but it works in 2 minutes if I remove
the spheres at the end points.

Looks like a bug in OpenScad triggered by unioning nearly coincident
faces.

On 14 June 2015 at 14:54, jon jon@jonbondy.com wrote:

Thank you very much.  You are very generous with your time.

Jon

On 6/14/2015 8:31 AM, nop head wrote:

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
myScale = 1/40;
hubR = 5;

function f(a,b,t) =  // spiral
[ (a + t * b) * cos(t),
(a + t * b) * sin(t),
0
];

$fn = 50;

function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1  ] ];

function m_rotate(v) =  [ [1,  0,        0,        0],
[0,  cos(v.x),  sin(v.x), 0],
[0, -sin(v.x),  cos(v.x), 0],
[0,  0,        0,        1] ]
* [ [ cos(v.y), 0,  -sin(v.y), 0],
[0,        1,  0,        0],
[ sin(v.y), 0,  cos(v.y), 0],
[0,        0,  0,        1] ]
* [ [ cos(v.z),  sin(v.z), 0, 0],
[-sin(v.z),  cos(v.z), 0, 0],
[ 0,        0,        1, 0],
[ 0,        0,        0, 1] ];

function vec3(v) = [v.x, v.y, v.z];
function transform(v, m)  = vec3([v.x, v.y, v.z, 1] * m);

function orientate(position, normal) = m_rotate([0,
atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0])
* m_rotate([0, 0, atan2(normal[1], normal[0])])
* m_translate(position);

function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r

  • cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ;

function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)],
path_points(a, b, step, t + step)) : [] ;

function transform_points(list, matrix, i = 0) = i < len(list) ?
concat([ transform(list[i], matrix) ], transform_points(list, matrix, i +
1)) : [];

function tube_points(profile, path, i = 0) = i < len(path) - 1
? concat(transform_points(profile,
orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path,
i + 1))
: transform_points(profile,
orientate(path[i], (path[i] - path[i - 1])/ 2)) ;

function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s *
facets + i,
s *
facets + (i + 1) % facets,
((s

    1. % segs) * facets + (i + 1) % facets,
      ((s
    1. % segs) * facets + i]],

tube_faces(segs, facets, s, i + 1)) : [];

function path_faces(segs, facets, i = 0) = i < segs - 1 ?
concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : [];

function cap(facets, segment = 0, i = 0) = i < facets ? concat(i +
facets * segment, cap(facets, segment, i + 1)) : [];

circle_points = circle_points(ballDiam / 2);
facets = len(circle_points);

path_points = path_points(hubR, myScale, 1);
segments = len(path_points);

tube_points = tube_points(circle_points, path_points);
path_faces = path_faces(segments, facets);

union() {
translate(path_points[0])
sphere(ballDiam / 2);

 polyhedron(points = tube_points, faces = concat([cap(facets)],

path_faces, [cap(facets, segments - 1)]));

 translate(path_points[segments - 1])
     sphere(ballDiam / 2);

}

On 14 June 2015 at 12:41, jon jon@jonbondy.com wrote:

I found and modified kit wallace's knot code (which is based on some
of your code).  Once I understood that the function at the top controlled
the entire object, it was indeed simple.  That is, the two of you made it
simple for me!  Not sure how to eliminate the requirement that the tube be
closed, though.

On 6/13/2015 8:55 PM, nop head wrote:

$fn = 50;
for (d = [0:1:720]) hull()

I think it will just take a very long time or consume all of the
memory because CGAL hates the massive implicit union of objects with lots
of vertices. It simply doesn't scale to high detail models. If you can
construct it with functions that generate lists to feed into polyhedron it
will be much faster.

See the work kitwallace did with knots. A spiral is not too different.

On 14 June 2015 at 01:35, jon jon@jonbondy.com wrote:

I can get this to work with F5, but not with F6: it just hangs for
hours, running full CPU.  Any thoughts?

rch = 0.1;
ballDiam = 25.4 * 1/4 + rch;
$fn = 50;

module spiral() {
myScale = 1/40;
hubR = 5;
for (d = [0:1:720]) {
hull(){
rotate([0, 0, d])
translate([hubR + d * myScale, 0, 0])
sphere(d = ballDiam);
rotate([0, 0, d])
translate([hubR + (d+1) * myScale, 0, 0])
sphere(d = ballDiam);

         }
     }

 };

difference() {
translate([0, 0, -ballDiam * 0.7])
cylinder(h=ballDiam, r=28);
spiral();
}


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date:
06/13/15


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


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date:
06/14/15


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

Actually it was caused by the winding order of one of the end caps being wrong. This fixes it: - function cap(facets, segment = 0, i = 0) = i < facets ? concat(segment ? facets * segment + i : facets - 1 - i, cap(facets, segment, i + 1)) : []; Also the sphere facets can be aligned with the tube by adding a rotation: translate(path_points[0]) rotate([0, 180 / $fn, 0]) sphere(ballDiam / 2); On 14 June 2015 at 15:17, nop head <nop.head@gmail.com> wrote: > PolySet has nonplanar faces. Attempting alternate construction > > ERROR: Alternate construction failed. CGAL error in > CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: > e->incident_sface() != SFace_const_handle() File: > /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h > Line: 326 > > > > On 14 June 2015 at 15:07, nop head <nop.head@gmail.com> wrote: > >> Unfortunately F6 fails on my system but it works in 2 minutes if I remove >> the spheres at the end points. >> >> Looks like a bug in OpenScad triggered by unioning nearly coincident >> faces. >> >> On 14 June 2015 at 14:54, jon <jon@jonbondy.com> wrote: >> >>> Thank you very much. You are very generous with your time. >>> >>> Jon >>> >>> >>> On 6/14/2015 8:31 AM, nop head wrote: >>> >>> rch = 0.1; >>> ballDiam = 25.4 * 1/4 + rch; >>> myScale = 1/40; >>> hubR = 5; >>> >>> function f(a,b,t) = // spiral >>> [ (a + t * b) * cos(t), >>> (a + t * b) * sin(t), >>> 0 >>> ]; >>> >>> $fn = 50; >>> >>> function m_translate(v) = [ [1, 0, 0, 0], >>> [0, 1, 0, 0], >>> [0, 0, 1, 0], >>> [v.x, v.y, v.z, 1 ] ]; >>> >>> function m_rotate(v) = [ [1, 0, 0, 0], >>> [0, cos(v.x), sin(v.x), 0], >>> [0, -sin(v.x), cos(v.x), 0], >>> [0, 0, 0, 1] ] >>> * [ [ cos(v.y), 0, -sin(v.y), 0], >>> [0, 1, 0, 0], >>> [ sin(v.y), 0, cos(v.y), 0], >>> [0, 0, 0, 1] ] >>> * [ [ cos(v.z), sin(v.z), 0, 0], >>> [-sin(v.z), cos(v.z), 0, 0], >>> [ 0, 0, 1, 0], >>> [ 0, 0, 0, 1] ]; >>> >>> function vec3(v) = [v.x, v.y, v.z]; >>> function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m); >>> >>> function orientate(position, normal) = m_rotate([0, >>> atan2(sqrt(pow(normal[0], 2) + pow(normal[1], 2)), normal[2]), 0]) >>> * m_rotate([0, 0, atan2(normal[1], normal[0])]) >>> * m_translate(position); >>> >>> function circle_points(r = 1, a = 0) = a < 360 ? concat([[r * sin(a), r >>> * cos(a), 0]], circle_points(r, a + 360 / $fn)) : [] ; >>> >>> function path_points(a, b, step, t = 0) = t <= 720 ? concat([f(a,b,t)], >>> path_points(a, b, step, t + step)) : [] ; >>> >>> function transform_points(list, matrix, i = 0) = i < len(list) ? >>> concat([ transform(list[i], matrix) ], transform_points(list, matrix, i + >>> 1)) : []; >>> >>> function tube_points(profile, path, i = 0) = i < len(path) - 1 >>> ? concat(transform_points(profile, >>> orientate(path[i], (path[i + 1] - path[i])/ 2)), tube_points(profile, path, >>> i + 1)) >>> : transform_points(profile, >>> orientate(path[i], (path[i] - path[i - 1])/ 2)) ; >>> >>> function tube_faces(segs, facets, s, i = 0) = i < facets ? concat([[s * >>> facets + i, >>> s * >>> facets + (i + 1) % facets, >>> ((s >>> + 1) % segs) * facets + (i + 1) % facets, >>> ((s >>> + 1) % segs) * facets + i]], >>> >>> tube_faces(segs, facets, s, i + 1)) : []; >>> >>> function path_faces(segs, facets, i = 0) = i < segs - 1 ? >>> concat(tube_faces(segs, facets, i), path_faces(segs, facets, i + 1)) : []; >>> >>> function cap(facets, segment = 0, i = 0) = i < facets ? concat(i + >>> facets * segment, cap(facets, segment, i + 1)) : []; >>> >>> circle_points = circle_points(ballDiam / 2); >>> facets = len(circle_points); >>> >>> path_points = path_points(hubR, myScale, 1); >>> segments = len(path_points); >>> >>> tube_points = tube_points(circle_points, path_points); >>> path_faces = path_faces(segments, facets); >>> >>> union() { >>> translate(path_points[0]) >>> sphere(ballDiam / 2); >>> >>> polyhedron(points = tube_points, faces = concat([cap(facets)], >>> path_faces, [cap(facets, segments - 1)])); >>> >>> translate(path_points[segments - 1]) >>> sphere(ballDiam / 2); >>> } >>> >>> >>> On 14 June 2015 at 12:41, jon <jon@jonbondy.com> wrote: >>> >>>> I found and modified kit wallace's knot code (which is based on some >>>> of your code). Once I understood that the function at the top controlled >>>> the entire object, it was indeed simple. That is, the two of you made it >>>> simple for me! Not sure how to eliminate the requirement that the tube be >>>> closed, though. >>>> >>>> On 6/13/2015 8:55 PM, nop head wrote: >>>> >>>> $fn = 50; >>>> for (d = [0:1:720]) hull() >>>> >>>> I think it will just take a very long time or consume all of the >>>> memory because CGAL hates the massive implicit union of objects with lots >>>> of vertices. It simply doesn't scale to high detail models. If you can >>>> construct it with functions that generate lists to feed into polyhedron it >>>> will be much faster. >>>> >>>> See the work kitwallace did with knots. A spiral is not too different. >>>> >>>> On 14 June 2015 at 01:35, jon <jon@jonbondy.com> wrote: >>>> >>>>> I can get this to work with F5, but not with F6: it just hangs for >>>>> hours, running full CPU. Any thoughts? >>>>> >>>>> >>>>> rch = 0.1; >>>>> ballDiam = 25.4 * 1/4 + rch; >>>>> $fn = 50; >>>>> >>>>> module spiral() { >>>>> myScale = 1/40; >>>>> hubR = 5; >>>>> for (d = [0:1:720]) { >>>>> hull(){ >>>>> rotate([0, 0, d]) >>>>> translate([hubR + d * myScale, 0, 0]) >>>>> sphere(d = ballDiam); >>>>> rotate([0, 0, d]) >>>>> translate([hubR + (d+1) * myScale, 0, 0]) >>>>> sphere(d = ballDiam); >>>>> >>>>> } >>>>> } >>>>> >>>>> }; >>>>> >>>>> difference() { >>>>> translate([0, 0, -ballDiam * 0.7]) >>>>> cylinder(h=ballDiam, r=28); >>>>> spiral(); >>>>> } >>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> Discuss@lists.openscad.org >>>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>> >>>> >>>> >>>> No virus found in this message. >>>> Checked by AVG - www.avg.com >>>> Version: 2015.0.6030 / Virus Database: 4360/10009 - Release Date: >>>> 06/13/15 >>>> >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>> >>>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >>> >>> No virus found in this message. >>> Checked by AVG - www.avg.com >>> Version: 2015.0.6030 / Virus Database: 4360/10012 - Release Date: >>> 06/14/15 >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >> >