Quantcast

F5 works, but not F6

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

F5 works, but not F6

jon_bondy
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

nophead
$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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


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

Re: F5 works, but not F6

jon_bondy
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

Chow 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

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

jon_bondy
In reply to this post by nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

nophead
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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

Re: F5 works, but not F6

jon_bondy
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

nophead
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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

Re: F5 works, but not F6

nophead
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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

Re: F5 works, but not F6

nophead
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





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

Re: F5 works, but not F6

nophead
Actually the rotation is only needed when $fn is a multiple of 4. It lines up without when $fn is a multiple of 2 and not at all if it is odd.

On 14 June 2015 at 15:41, nop head <[hidden email]> wrote:
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




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


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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org






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

Re: F5 works, but not F6

bdl
In reply to this post by jon_bondy
I'm hitting this as well.  I wrote a module to do "shift_extrude" and it works nicely with F5 preview.  For F6 rendering, if I only have one shifted extrusion, it's fine, but if I add a second, I get:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /opt/mxe/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326

I extracted the minimum code to reproduce the error:
 bug_report.scad

Oddly enough, it doesn't seem to be a matter of the number of slices.  I tried changing the number of slices to 10 to reduce the number of vertices and it still fails.  Even with the separation between the two objects.
tp3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

tp3
On 02/19/2017 04:03 AM, bdl wrote:
> I extracted the minimum code to reproduce the error:
>   bug_report.scad <http://forum.openscad.org/file/n20483/bug_report.scad>  
>
The winding order of some faces is wrong.

See
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_is_my_model_showing_up_with_F5_but_not_F6.3F

ciao,
  Torsten.


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

Re: F5 works, but not F6

bdl
Yeah, I just figured that out while playing around.

My regular_polygon winds counterclockwise in the plane, to the top and bottom faces are wrong if height > 0 and all the other faces are wrong if height < 0.  I fixed it and now things seem to be working.

What's odd is I've had errors in face winding before and never gotten that error... usually things just look funny... but maybe I was only using F5 in those cases and just didn't notice the problem here.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

Parkinbot
In reply to this post by nophead
well done nophead. This is a version using my sweep():

use <Naca_sweep.scad>
$fn=50;
spiral(a1 = 120, a2 = 960, r=22, rc=10);

module spiral(a1=180, a2=720, r=25, rc=10)
{
  sweep(gendat(a1, a2, r, rc));
  translate(spiral_(a1, r)) sphere(rc);
  translate(spiral_(a2, r)) sphere(rc);
}

function gendat(a1=180, a2=720, r=25, rc=10) = let(N=$fn?$fn:360/$fa, M=ceil((a2-a1)/360*N), st = (a2-a1)/M)
  [for(i=[0:M]) let(a=i*st+a1) traject(circle_(rc), direction_(a), spiral_(a, r))]; // compose all trajectory data

function circle_(r=10, n=undef) = let(N=n?n:$fn?$fn:360/$fa, st = 360/N)
  [for(i=[0:N-1]) [r*cos(i*st), 0, r*sin(i*st)]]; // 2D shape

function spiral_(a, r) = r*a/360*[sin(a), cos(a)]; // archimedes spiral

function direction_(a, r=10) = let(p1 = spiral_(a-.5, r), p2 = spiral_(a+.5, r)) (p2-p1)/norm(p2-p1); // direction vector needed for rotation

function traject(L, v, t) = let(rot = [[v[1], -v[0], 0],[-v[0], v[1], 0], [0, 0, 1]])
  [for(i=L) rot*i+[t[0], t[1], 0]]; // rotate + translate to place circle into trajectory
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: F5 works, but not F6

nophead
Nice. A bit simpler than mine!


On 19 February 2017 at 18:53, Parkinbot <[hidden email]> wrote:
well done nophead. This is a version using my sweep():


> use
> <Naca_sweep.scad>
> $fn=50;
> spiral(a1 = 120, a2 = 960, r=22, rc=10);
>
> module spiral(a1=180, a2=720, r=25, rc=10)
> {
>   sweep(gendat(a1, a2, r, rc));
>   translate(spiral_(a1, r)) sphere(rc);
>   translate(spiral_(a2, r)) sphere(rc);
> }
>
> function gendat(a1=180, a2=720, r=25, rc=10) = let(N=$fn?$fn:360/$fa,
> M=ceil((a2-a1)/360*N), st = (a2-a1)/M)
>   [for(i=[0:M]) let(a=i*st+a1) traject(circle_(rc), direction_(a),
> spiral_(a, r))]; // compose all trajectory data
>
> function circle_(r=10, n=undef) = let(N=n?n:$fn?$fn:360/$fa, st = 360/N)
>   [for(i=[0:N-1]) [r*cos(i*st), 0, r*sin(i*st)]]; // 2D shape
>
> function spiral_(a, r) = r*a/360*[sin(a), cos(a)]; // archimedes spiral
>
> function direction_(a, r=10) = let(p1 = spiral_(a-.5, r), p2 =
> spiral_(a+.5, r)) (p2-p1)/norm(p2-p1); // direction vector needed for
> rotation
>
> function traject(L, v, t) = let(rot = [[v[1], -v[0], 0],[-v[0], v[1], 0],
> [0, 0, 1]])
>   [for(i=L) rot*i+[t[0], t[1], 0]]; // rotate + translate to place circle
> into trajectory





--
View this message in context: http://forum.openscad.org/F5-works-but-not-F6-tp12875p20493.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

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


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

Re: F5 works, but not F6

Ronaldo
With a bit more code, the spherical caps may be include in the polyhedron definition. The following code is a self contained specialized sweep for circular sections with spherical caps. The path can be easily changed from the spiral to something else. F6 takes virtually nothing and don't crash when boolean operated if the polyhedron has no self-intersections.

<code>
R_ini   = 20;
R_end   = 100;
ang_ini = 0;
ang_end = 800;
long_n  = 200;
sect_n  = 32;
diam    = 20;

spiral_path = spiral(R_ini, R_end, ang_ini, ang_end, long_n);
spiral_tube = tube(spiral_path, diam/2, sect_n);

difference(){
    mesh2poly(spiral_tube);
// uncomment to check F6
//    translate([(R_ini+R_end)/5, (R_ini+R_end)/5, 0]) cube(3*diam);
}

// build a mesh for the whole tube with spherical caps
function tube(path, r, n) =
    let( m= len(path),
         tube_ = [for(i=[0:m-1] ) // the tube itself
                    let( pt  = path[i],
                         // tangent at path[i]
                         tg  = unit(path[min(i+1,m-1)]-path[max(i-1,0)]),
                         c   =  tg.y,
                         s   = -tg.x,
                         cir = circle_(r, n)*[[c,s,0],[-s,c,0],[0,0,1]])
                    [for(p=cir) p+pt]
                 ],
          tgi  = path[0]-path[1],
          tgf  = path[m-1]-path[m-2],
          capi = spherical_cap(tube_[0],   r*unit(tgi), path[0],   true,  floor(n/4)),
          capf = spherical_cap(tube_[m-1], r*unit(tgf), path[m-1], false, floor(n/4)) )
    concat( capi, tube_ , capf );

// a half sphere to close the tube
function spherical_cap(cir, tg, ct, start, n) =
    let( m = len(cir),
         cir0 = [for(p=cir) p-ct ],
         rang = start? [n:-1:0] : [0:n] )
    [for(i=rang) let(c=cos(90*i/n)*cir0, s=sin(90*i/n))
        [for(p=c) p+s*tg+ct ] ];

// a spiraled path
function spiral(r1, r2, a1, a2, m) =
    let( da = (a2-a1)/m )
    [for(i=[0:m], ai = a1 + i*da, ri = r1 + (r2-r1)*i/m )
        ri*[cos(ai), sin(ai),0*cos(ai/3)] ];

function circle_(r,n) =
    [for(i=[0:n]) r*[cos(360*i/n),0,sin(360*i/n)]  ] ;

// draw a mesh (matrix of points) as a polyhedron
module mesh2poly(rmesh) {
    n = len(rmesh) ;
    m = len(rmesh[0]) ;
    vertices = [ for(i=[n-1: -1: 0]) for(pt=rmesh[i]) pt ];    
    tris = concat(  [ for(i=[0:n-2],j=[0:m-2])
                        [ i*m+j, (i+1)*m+j, (i+1)*m+j+1 ] ] ,
                    [ for(i=[0:n-2],j=[0:m-2])
                        [ i*m+j, (i+1)*m+j+1, i*m+j+1 ] ] );
    polyhedron(vertices, tris);
}

function unit(v) = v/norm(v);
</code>
Loading...