# Compensating for the difference in height of objects created with linear_extrude with different twist values

5 messages
Open this post in threaded view
|

## Compensating for the difference in height of objects created with linear_extrude with different twist values

 I've created a module which generates a corkscrew with varying pitch (decreasing or increasing, depending on the parameter r): module foo(n,r,angle,total_height) {     assert(r!=1,"r=1 special case not supported");     series_ratio = (1-pow(r,n))/(1-r);     a = total_height/series_ratio;     for (i=[0:n-1])     {         total_h= a*(1-pow(r,i))/(1-r);         total_angle = i*angle/n;         translate([0,0,total_h])         rotate([0,0,-total_angle])         linear_extrude(height = a*pow(r,i),twist = angle/n,slices=10) children();     }     } *My problem:* The height (or the width, or the size of the cross section... call it what you will) changes then the ratio of the twist and height grows). It's easier to see when taking the difference between a cylinder and the result: difference() {     cylinder(h=52,r=3); foo(10,0.7,720,50) translate([3,0,0]) circle(0.4); } I've tried scaling in the z dimension by various functions, such as the inverse of pow(r,i) (which is too large). I suspect the right scaling value has to do with the pitch, which (I think?) is inversely related to the ratio of twist to height, but because it's rotating around z, I can't figure the math out and keep going in circles... -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Compensating for the difference in height of objects created with linear_extrude with different twist values

 Note sure what you are expecting. With F5 I see some z-fighting where the ends meet. With F6, as long as I flush the cache first, I get a manifold result. Adding render() causes it to look OK with F5.Somewhat surprising as stacking objects with irrational lengths would normally lead to problems with floating point rounding.When stacking objects one would normally want a slight overlap to avoid z fighting but with this shape it is hard to arrange because extending a section causes a slight lateral misalignment. This was with the latest snapshot and I think there have been some improvements to linear_extrude with twist since the last release. What are you seeing?On Sun, 20 Sep 2020 at 19:21, int_i <[hidden email]> wrote:I've created a module which generates a corkscrew with varying pitch (decreasing or increasing, depending on the parameter r): module foo(n,r,angle,total_height) {     assert(r!=1,"r=1 special case not supported");     series_ratio = (1-pow(r,n))/(1-r);     a = total_height/series_ratio;     for (i=[0:n-1])     {         total_h= a*(1-pow(r,i))/(1-r);         total_angle = i*angle/n;         translate([0,0,total_h])         rotate([0,0,-total_angle])         linear_extrude(height = a*pow(r,i),twist = angle/n,slices=10) children();     } } *My problem:* The height (or the width, or the size of the cross section... call it what you will) changes then the ratio of the twist and height grows). It's easier to see when taking the difference between a cylinder and the result: difference() {     cylinder(h=52,r=3); foo(10,0.7,720,50) translate([3,0,0]) circle(0.4); } I've tried scaling in the z dimension by various functions, such as the inverse of pow(r,i) (which is too large). I suspect the right scaling value has to do with the pitch, which (I think?) is inversely related to the ratio of twist to height, but because it's rotating around z, I can't figure the math out and keep going in circles... -- Sent from: http://forum.openscad.org/ _______________________________________________ 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
Open this post in threaded view
|

## Re: Compensating for the difference in height of objects created with linear_extrude with different twist values

 I'm seeing different widths on the lines. Hard to see unless you take the difference from the cylinder. will try with the development snapshot later. not easy using a laptop when a bunch of random keys stop working, and not fun using the on-screen keyboard to compensate... -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org