discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] how to make the groove more width?

FV
Frank van der Hulst
Wed, Jan 18, 2017 6:39 PM

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" rudolf@parkinbot.com 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 = R2PI;
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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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" <rudolf@parkinbot.com> 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 Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
R
runsun
Thu, Jan 19, 2017 12:35 AM

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: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: Collection of tips on github

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20163.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

>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: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: Collection of tips on github -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20163.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Jan 19, 2017 1:30 PM

As I wrote the approach is limited. For to do springs, it needs more.

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20165.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

As I wrote the approach is limited. For to do springs, it needs more. -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20165.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Thu, Jan 19, 2017 2:10 PM

2017-01-19 11:30 GMT-02:00 Parkinbot rudolf@parkinbot.com:

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.

2017-01-19 11:30 GMT-02:00 Parkinbot <rudolf@parkinbot.com>: > 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.
P
Parkinbot
Thu, Jan 19, 2017 3:22 PM

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.

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20167.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

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. -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20167.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Fri, Jan 20, 2017 1:55 AM

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(2RPI/360twist/h),
f = a==0?1:tan(a)/sin(a))  // factor
[for(i=[0:10:359])
let(v=[r
sin(i)+R, frcos(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.

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.
RP
Ronaldo Persiano
Fri, Jan 20, 2017 2:25 PM

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(2RPI/360twist/h),
// f = a==0?1:tan(a)/sin(a))  // factor
f = h==0? 1: norm([2
RPI/360twist,h])/h)  // factor
/* [for(i=[0:120:359])
let(v=[rsin(i+90)+R, frcos(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 rudolf@parkinbot.com:

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(2RPI/360twist/h),
f = a==0?1:tan(a)/sin(a))  // factor
[for(i=[0:10:359])
let(v=[r
sin(i)+R, frcos(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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <rudolf@parkinbot.com>: > 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Fri, Jan 20, 2017 5:42 PM

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.

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.
RP
Ronaldo Persiano
Fri, Jan 20, 2017 6:13 PM

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 rudolf@parkinbot.com:

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <rudolf@parkinbot.com>: > 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
runsun
Sat, Jan 21, 2017 6:32 AM

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: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: Collection of tips on github

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20181.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

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: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: Collection of tips on github -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20181.html Sent from the OpenSCAD mailing list archive at Nabble.com.