how to make the groove more width?

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

how to make the groove more width?

eexpss
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);
        }
    }
}

Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Parkinbot
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

$fn= 30;
h = 60;
OR = 12;
r = .5;
g = OR;
tw = 720;  // use negative value for CCW
N=4;

slot();
module slot(groove = true){
  difference()
  {
    cylinder(h,r=OR,center=true);
    if(groove){
      for(w=[0:N-1])
        linear_extrude(height=h+.1, center=true, convexity=2, twist=tw)
        rotate([0, 0, w*360/N])
        translate([g, 0, 0])
        groove_shape(h, tw, OR, r) circle(r=r);
     }
  }
}

module groove_shape(h=1, twist=0, R, r) // operator module
{
    U = R*2*PI;
    x = U/360*twist;
    a = atan(x/h);
    f = a==0?1:tan(a)/sin(a);
    scale([1, f])
    children();
}
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

frankv
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
angle. This is not so easy to do, because 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


> $fn= 30;
> h = 60;
> OR = 12;
> r = .5;
> g = OR;
> tw = 720;  // use negative value for CCW
> N=4;
>
> slot();
> module slot(groove = true){
>   difference()
>   {
>     cylinder(h,r=OR,center=true);
>     if(groove){
>       for(w=[0:N-1])
>         linear_extrude(height=h+.1, center=true, convexity=2, twist=tw)
>         rotate([0, 0, w*360/N])
>         translate([g, 0, 0])
>         groove_shape(h, tw, OR, r) circle(r=r);
>      }
>   }
> }
>
> module groove_shape(h=1, twist=0, R, r) // operator module
> {
>     U = R*2*PI;
>     x = U/360*twist;
>     a = atan(x/h);
>     f = a==0?1:tan(a)/sin(a);
>     scale([1, f])
>     children();
> }





--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20158.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
|

Re: how to make the groove more width?

runsun
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
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

eexpss
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
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Parkinbot
In reply to this post by runsun
As I wrote the approach is limited. For to do springs, it needs more.
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Ronaldo
2017-01-19 11:30 GMT-02:00 Parkinbot <[hidden email]>:
As I wrote the approach is limited. For to do springs, it needs more.
 
Would you elaborate on that? I don't see any way to get a circular transversal section from a linear_extrude.



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

Re: how to make the groove more width?

Parkinbot
Ronaldo wrote
Would you elaborate on that?
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.
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

eexpss
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

Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Parkinbot
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 non-affine, so you can't express it with multmatrix.



R=12;
h=60;
r = 2;
twist = 720;

linear_extrude(height = h, twist = twist, slices = 600)
  polygon(groove_circle(R, r, twist, h));

function groove_circle(R=30, r=7, twist, h) =
let(a = atan(2*R*PI/360*twist/h),
    f = a==0?1:tan(a)/sin(a))  // factor
 [for(i=[0:10:359])
   let(v=[r*sin(i)+R, f*r*cos(i)])
   (R+v[0])*v/norm(v)];  // radial transformation
 
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Ronaldo
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]*(10-j)/10+v[(i+1)%3]*j/10 )
        let(n2 = norm(w)) // radial transformation
        (R+w[0])*w/n2];

Thank you to point me out that linear_extrude twist could be properly used to sweep any shape along a helical path.

BTW, I have changed your computation of the f factor to a simpler expression without trigs.

2017-01-19 23:55 GMT-02:00 Parkinbot <[hidden email]>:
Ronaldo, this is your linear_extrude circle with radial transformation. As I
said it gets worse with the ratio growing. The transformation is non-affine,
so you can't express it with multmatrix.

<http://forum.openscad.org/file/n20170/Spring.png>


> R=12;
> h=100;
> r = 2;
> twist = 720;
>
> linear_extrude(height = h, twist = twist, slices = 200)
>   polygon(groove_circle(R, r, twist, h));
>
> function groove_circle(R=30, r=7, twist, h) =
> let(a = atan(2*R*PI/360*twist/h),
>     f = a==0?1:tan(a)/sin(a))  // factor
>  [for(i=[0:10:359])
>    let(v=[r*sin(i)+R, f*r*cos(i)])
>    let(n2 = sqrt(v[0]*v[0]+v[1]*v[1])) // radial transformation
>    (R+v[0])*v/n2];





--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20170.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
|

Re: how to make the groove more width?

Parkinbot
Ronaldo,

thanks for going through my code, your optimizations and hints. Yes, it is no surprise that a non-affine projection can/will transform lines into curves. In the given case the x-dimension 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.

Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Ronaldo
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.

2017-01-20 15:42 GMT-02:00 Parkinbot <[hidden email]>:
Ronaldo,

thanks for going through my code, your optimizations and hints. Yes, it is
no surprise that a non-affine projection can/will transform lines into
curves. In the given case the x-dimension 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.





--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20173.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
|

Re: how to make the groove more width?

runsun
In reply to this post by Parkinbot
Parkinbot wrote
... As I said it gets worse with the ratio growing.
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
Reply | Threaded
Open this post in threaded view
|

Re: how to make the groove more width?

Parkinbot
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.

runsun wrote
What ratio did you infer to ? Can't figure it out from your code.