This post has NOT been accepted by the mailing list yet.
I want make groove on the surface of a cylinder. I use twist, but the groove is narrow.
module slot(unichar, groove){ difference(){ cylinder(h,r=OR,center=true); if(groove){ for(g=[[OR,0,0],[0,OR,0],[OR,0,0],[0,OR,0]]) linear_extrude(height=h, center=true, convexity=1, twist=720)translate(g)circle(r = 0.5); } } } 
This post was updated on .
I guess you want the groove to keep its shape independently of the twist angle. This is not so easy to do, because you need a proper helix object for difference. There is some threading code out there (e.g. Thingiverse) to do this.
With some limitation it can also be created by linear_extrude(), but it needs an ellipse that exactly compensates the angle introduced by the twist. The following code introduces an operator doing this and rewrites your code partly for proper application

I'm not sure what you're trying to do (can't see the original message on my phone) but it may be that minkowski would help? I'm thinking something like difference your original from a bounding cube to get a female mould. Then minkowski the female mould to expand it, and difference that from the original. Frank On 19/01/2017 04:30, "Parkinbot" <[hidden email]> wrote: I guess you want the groove to keep its shape independently of the twist _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org 
From my understanding, Parkinbot's post is the solution to your question. It's also a good demo or making a spring, I believe.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets 
In reply to this post by Parkinbot
I catch it. the most import is scale(), so I modify my code simply like this:
if(groove){ for(g=[[OR,0],[0,OR],[OR,0],[0,OR]]) linear_extrude(height=h, center=true, convexity=1, twist=720)translate(g)scale(g[0]==0?[3, 1]:[1,3])circle(r = 0.5); } thanks. those trigonometric make me dizzy, so i just add an simple judgement. lol 
In reply to this post by runsun
As I wrote the approach is limited. For to do springs, it needs more.

20170119 11:30 GMT02:00 Parkinbot <[hidden email]>: Would you elaborate on that? I don't see any way to get a circular transversal section from a linear_extrude.As I wrote the approach is limited. For to do springs, it needs more. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org 
As long as nobody provides a definition for "side tracking a thread" I'll try. An ellipse is just an approximation of the proper shape. It can be used to carve grooves as in the example, but ... you name it. It lacks a radial transformation and thus gets worse with growing twist/height ratio. But if you take a perfect spring object and calculate a 2D shape from it, using projection(cut=true), you will obviously get a shape so that linear_extrude() does what you want. Of course in a practical sense there are restrictions. 
This post was updated on .
In reply to this post by eexpss
Now I find does not need change scale parameter.
for(g=[0,45,90,45,90,135,135,180])//rotate for(tw=[720,720]) linear_extrude(height=h, center=true, twist=tw)rotate([0,0,g])scale([1,5])translate([OR,0])circle(r = 0.5); or 
This post was updated on .
In reply to this post by Ronaldo
Ronaldo, this is your linear_extrude circle with radial transformation. As I said it gets worse with the ratio growing. The transformation is nonaffine, so you can't express it with multmatrix.

Thanks, Rudolf. You saved me the trouble of checking your helical projections. I have tried some changes in your code and observed that the helix section is poor when the number of points in the circle is drastically reduced to 3 or 4 points, that means when the section is a triangle or square instead of a circle. Then I realized that I should finely resample the polygon (triangle or square) to get a better helical projection. And that is enough to correct the helix section shape. That is the code I have used:function groove_triangle(R=30, r=7, twist, h) = let(// a = atan(2*R*PI/360*twist/h), // f = a==0?1:tan(a)/sin(a)) // factor f = h==0? 1: norm([2*R*PI/360*twist,h])/h) // factor /* [for(i=[0:120:359]) let(v=[r*sin(i+90)+R, f*r*cos(i+90)]) let(n2 = sqrt(v[0]*v[0]+v[1]*v[1])) // radial transformation (R+v[0])*v/n2];*/ let(v = [for(i=[0:120:359]) [r*sin(i+90)+R, f*r*cos(i+90)]]) [ for(i=[0:2], j=[0:9]) let( w = v[i]*(10j)/10+v[(i+1)%3]*j/10 ) let(n2 = norm(w)) // radial transformation (R+w[0])*w/n2]; 20170119 23:55 GMT02:00 Parkinbot <[hidden email]>: Ronaldo, this is your linear_extrude circle with radial transformation. As I _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org 
Ronaldo,
thanks for going through my code, your optimizations and hints. Yes, it is no surprise that a nonaffine projection can/will transform lines into curves. In the given case the xdimension has to go through a circular projection to get the job done. So the solution needs a skilled hammerer and special nails  and is obviously beyond the scope of native OpenSCAD. Which "helical projections" do you mean? The gears are already in radial form and my springs and coils lib doesn't use this weired approach. Of course, a proper sweep() (or hull() discretisation) over an orthogonally oriented extrusion shape is the best approach. 
I have called "helical projection" what you call circular projection. But your skilled hammer, as any other tool, has its own limitation. It doesn't reproduce a sweep for lower h values. Neither even two giants, Newton and Einstein, created tools for all scales.20170120 15:42 GMT02:00 Parkinbot <[hidden email]>: Ronaldo, _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org 
In reply to this post by Parkinbot
What ratio did you infer to ? Can't figure it out from your code.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets 
Imagine you start with a cylinder and want to tilt that into the groove. Then the factor has to grow when radius or twist increase or when the height gets lesser.

Free forum by Nabble  Edit this page 