discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Rounding convex edges without minkowski?

N
Neon22
Fri, Jun 2, 2017 10:20 PM

The functions filled_torus and torus are missing ?

--
View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21631.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The functions filled_torus and torus are missing ? -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21631.html Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jsc
Sat, Jun 3, 2017 12:23 AM

Excellent. I had to adjust some of the parameters to get the dimensions to
work out correctly, but the general scheme worked out very well. Rendering
is much faster, and the preview version is no longer needed. I updated the
script and credited you in the code, although only as "Ronaldo". Thank you.

--
View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21632.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Excellent. I had to adjust some of the parameters to get the dimensions to work out correctly, but the general scheme worked out very well. Rendering is much faster, and the preview version is no longer needed. I updated the script and credited you in the code, although only as "Ronaldo". Thank you. -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21632.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
caterpillar
Sat, Jun 3, 2017 3:25 AM

I tried to come up with my solution. First, I created a
two_connected_circles module:

include <rotate_p.scad>;
include <bezier_curve.scad>;
include <rounded_extrude.scad>;

$fn = 36;

radius = 10;
leng = 40;
t_step = 0.1;
tangent_angle = 40;

module two_connected_circles(radius, dist, tangent_angle, t_step) {
half_dist = dist / 2;

p1 = rotate_p([0, -radius], tangent_angle) + [-half_dist, 0];
p2 = rotate_p([radius * tan(tangent_angle), -radius], tangent_angle) +

[-half_dist, 0];

p3 = [-p1[0], p1[1]];
p4 = [-p2[0], p2[1]];

curve_pts = bezier_curve(t_step, [p1, p2, p4, p3]);
leng_pts = len(curve_pts);

upper_curve_pts = 
    [
        for(i = [0:leng_pts - 1]) 
            curve_pts[leng_pts - i - 1]
    ];
lower_curve_pts = 
    [
        for(pt = curve_pts) 
            [pt[0], -pt[1]]
    ];

translate([-half_dist, 0]) 
    circle(radius); 
translate([half_dist, 0]) 
    circle(radius);
    
polygon(
    concat(
        upper_curve_pts, 
        lower_curve_pts
    )
);

}

two_connected_circles(
radius, leng, tangent_angle, t_step
);

http://forum.openscad.org/file/n21633/two_connected_circles.jpg

After that, I created a tri_connected_circles module:

module tri_connected_circles(radius, leng, tangent_angle, t_step) {
angle = 60;
half_leng = leng / 2;

module two_circles() {
    two_connected_circles(radius, leng, tangent_angle, t_step, round_r);
}

translate([0, -half_leng * tan(30), 0]) union() {
    two_circles();

    translate([-half_leng, 0, 0])
        rotate(angle) 
            translate([half_leng, 0, 0]) 
                two_circles();

    translate([half_leng, 0, 0])
        rotate(-angle) 
            translate([-half_leng, 0, 0]) 
                two_circles();
}

}

tri_connected_circles(radius, leng, tangent_angle, t_step);

http://forum.openscad.org/file/n21633/tri_connected_circles.jpg

Then, I can rounded it by the following code:

round_r = 3;

rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r,
180)
union() {
circle(radius * 1.5);
tri_connected_circles(radius, leng, tangent_angle, t_step);
}

http://forum.openscad.org/file/n21633/rounded_connected_circles.jpg

The complete code:

include <rotate_p.scad>;
include <bezier_curve.scad>;
include <rounded_extrude.scad>;

$fn = 36;

radius = 10;
leng = 40;
t_step = 0.1;
tangent_angle = 40;
round_r = 3;

module two_connected_circles(radius, dist, tangent_angle, t_step) {
half_dist = dist / 2;

p1 = rotate_p([0, -radius], tangent_angle) + [-half_dist, 0];
p2 = rotate_p([radius * tan(tangent_angle), -radius], tangent_angle) +

[-half_dist, 0];

p3 = [-p1[0], p1[1]];
p4 = [-p2[0], p2[1]];

curve_pts = bezier_curve(t_step, [p1, p2, p4, p3]);
leng_pts = len(curve_pts);

upper_curve_pts = 
    [
        for(i = [0:leng_pts - 1]) 
            curve_pts[leng_pts - i - 1]
    ];
lower_curve_pts = 
    [
        for(pt = curve_pts) 
            [pt[0], -pt[1]]
    ];

translate([-half_dist, 0]) 
    circle(radius); 
translate([half_dist, 0]) 
    circle(radius);
    
polygon(
    concat(
        upper_curve_pts, 
        lower_curve_pts
    )
);

}

module tri_connected_circles(radius, leng, tangent_angle, t_step) {
angle = 60;
half_leng = leng / 2;

module two_circles() {
    two_connected_circles(radius, leng, tangent_angle, t_step, round_r);
}

translate([0, -half_leng * tan(30), 0]) union() {
    two_circles();

    translate([-half_leng, 0, 0])
        rotate(angle) 
            translate([half_leng, 0, 0]) 
                two_circles();

    translate([half_leng, 0, 0])
        rotate(-angle) 
            translate([-half_leng, 0, 0]) 
                two_circles();
}

}

  • two_connected_circles(
    radius, leng, tangent_angle, t_step
    );

  • tri_connected_circles(radius, leng, tangent_angle, t_step);

rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r,
180)
union() {
circle(radius * 1.5);
tri_connected_circles(radius, leng, tangent_angle, t_step);
}

You can find include rotate_p.scad, bezier_curve.scad, rounded_extrude.scad
here:
https://justinsdk.github.io/dotSCAD/


http://openhome.cc

View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21633.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I tried to come up with my solution. First, I created a *two_connected_circles* module: include <rotate_p.scad>; include <bezier_curve.scad>; include <rounded_extrude.scad>; $fn = 36; radius = 10; leng = 40; t_step = 0.1; tangent_angle = 40; module two_connected_circles(radius, dist, tangent_angle, t_step) { half_dist = dist / 2; p1 = rotate_p([0, -radius], tangent_angle) + [-half_dist, 0]; p2 = rotate_p([radius * tan(tangent_angle), -radius], tangent_angle) + [-half_dist, 0]; p3 = [-p1[0], p1[1]]; p4 = [-p2[0], p2[1]]; curve_pts = bezier_curve(t_step, [p1, p2, p4, p3]); leng_pts = len(curve_pts); upper_curve_pts = [ for(i = [0:leng_pts - 1]) curve_pts[leng_pts - i - 1] ]; lower_curve_pts = [ for(pt = curve_pts) [pt[0], -pt[1]] ]; translate([-half_dist, 0]) circle(radius); translate([half_dist, 0]) circle(radius); polygon( concat( upper_curve_pts, lower_curve_pts ) ); } two_connected_circles( radius, leng, tangent_angle, t_step ); <http://forum.openscad.org/file/n21633/two_connected_circles.jpg> After that, I created a *tri_connected_circles* module: module tri_connected_circles(radius, leng, tangent_angle, t_step) { angle = 60; half_leng = leng / 2; module two_circles() { two_connected_circles(radius, leng, tangent_angle, t_step, round_r); } translate([0, -half_leng * tan(30), 0]) union() { two_circles(); translate([-half_leng, 0, 0]) rotate(angle) translate([half_leng, 0, 0]) two_circles(); translate([half_leng, 0, 0]) rotate(-angle) translate([-half_leng, 0, 0]) two_circles(); } } tri_connected_circles(radius, leng, tangent_angle, t_step); <http://forum.openscad.org/file/n21633/tri_connected_circles.jpg> Then, I can rounded it by the following code: round_r = 3; rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r, 180) union() { circle(radius * 1.5); tri_connected_circles(radius, leng, tangent_angle, t_step); } <http://forum.openscad.org/file/n21633/rounded_connected_circles.jpg> The complete code: include <rotate_p.scad>; include <bezier_curve.scad>; include <rounded_extrude.scad>; $fn = 36; radius = 10; leng = 40; t_step = 0.1; tangent_angle = 40; round_r = 3; module two_connected_circles(radius, dist, tangent_angle, t_step) { half_dist = dist / 2; p1 = rotate_p([0, -radius], tangent_angle) + [-half_dist, 0]; p2 = rotate_p([radius * tan(tangent_angle), -radius], tangent_angle) + [-half_dist, 0]; p3 = [-p1[0], p1[1]]; p4 = [-p2[0], p2[1]]; curve_pts = bezier_curve(t_step, [p1, p2, p4, p3]); leng_pts = len(curve_pts); upper_curve_pts = [ for(i = [0:leng_pts - 1]) curve_pts[leng_pts - i - 1] ]; lower_curve_pts = [ for(pt = curve_pts) [pt[0], -pt[1]] ]; translate([-half_dist, 0]) circle(radius); translate([half_dist, 0]) circle(radius); polygon( concat( upper_curve_pts, lower_curve_pts ) ); } module tri_connected_circles(radius, leng, tangent_angle, t_step) { angle = 60; half_leng = leng / 2; module two_circles() { two_connected_circles(radius, leng, tangent_angle, t_step, round_r); } translate([0, -half_leng * tan(30), 0]) union() { two_circles(); translate([-half_leng, 0, 0]) rotate(angle) translate([half_leng, 0, 0]) two_circles(); translate([half_leng, 0, 0]) rotate(-angle) translate([-half_leng, 0, 0]) two_circles(); } } * two_connected_circles( radius, leng, tangent_angle, t_step ); * tri_connected_circles(radius, leng, tangent_angle, t_step); rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r, 180) union() { circle(radius * 1.5); tri_connected_circles(radius, leng, tangent_angle, t_step); } You can find include rotate_p.scad, bezier_curve.scad, rounded_extrude.scad here: https://justinsdk.github.io/dotSCAD/ ----- http://openhome.cc -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21633.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Sat, Jun 3, 2017 7:05 AM

You are right. Here they are:

module torus(R,r) rotate_extrude() translate([R,0,0]) circle(r);

module filled_torus(R,r) { torus(R,r); cylinder(r=R,h=2*r, center=true); }

2017-06-02 19:20 GMT-03:00 Neon22 mschafer@wireframe.biz:

The functions filled_torus and torus are missing ?

You are right. Here they are: module torus(R,r) rotate_extrude() translate([R,0,0]) circle(r); module filled_torus(R,r) { torus(R,r); cylinder(r=R,h=2*r, center=true); } 2017-06-02 19:20 GMT-03:00 Neon22 <mschafer@wireframe.biz>: > The functions filled_torus and torus are missing ? > >
C
caterpillar
Sat, Jun 3, 2017 1:43 PM

I added a shape_glued2circles function into  my library
https://justinsdk.github.io/dotSCAD/  . Now, we can simplify the code:

include <rotate_p.scad>;
include <bezier_curve.scad>;
include <shape_pie.scad>;
include <shape_glued2circles.scad>;
include <rounded_extrude.scad>;

$fn = 48;

radius = 10;
leng = 40;
tangent_angle = 40;
round_r = 3;

module tri_connected_circles(radius, leng, tangent_angle) {
angle = 60;
half_leng = leng / 2;

module two_circles() { 
    polygon(
        shape_glued2circles(radius, leng, tangent_angle = tangent_angle)
    );
} 

translate([0, -half_leng * tan(30), 0]) union() { 
    two_circles(); 

    translate([-half_leng, 0, 0]) 
        rotate(angle) 
            translate([half_leng, 0, 0]) 
                two_circles(); 

    translate([half_leng, 0, 0]) 
        rotate(-angle) 
            translate([-half_leng, 0, 0]) 
                two_circles(); 
} 

}

rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r,
180)
union() {
circle(radius * 1.5);
tri_connected_circles(radius, leng, tangent_angle);
}


http://openhome.cc

View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21636.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I added a *shape_glued2circles* function into my library <https://justinsdk.github.io/dotSCAD/> . Now, we can simplify the code: include <rotate_p.scad>; include <bezier_curve.scad>; include <shape_pie.scad>; include <shape_glued2circles.scad>; include <rounded_extrude.scad>; $fn = 48; radius = 10; leng = 40; tangent_angle = 40; round_r = 3; module tri_connected_circles(radius, leng, tangent_angle) { angle = 60; half_leng = leng / 2; module two_circles() { polygon( shape_glued2circles(radius, leng, tangent_angle = tangent_angle) ); } translate([0, -half_leng * tan(30), 0]) union() { two_circles(); translate([-half_leng, 0, 0]) rotate(angle) translate([half_leng, 0, 0]) two_circles(); translate([half_leng, 0, 0]) rotate(-angle) translate([-half_leng, 0, 0]) two_circles(); } } rounded_extrude([leng + 2 * radius, leng * tan(60) + 2 * radius], round_r, 180) union() { circle(radius * 1.5); tri_connected_circles(radius, leng, tangent_angle); } ----- http://openhome.cc -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21636.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Jun 4, 2017 11:19 PM

here a nice and simple constructor:

offset(-15) offset(12) forN(r=26, N=3) circle(20);
module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0,
0]) children();

WITH minkowski the code for the fidget is quite straight forward. 4 minute
render time is not at all bad.

$fn=40;          // use 10 for experiments, 40 for finals (4min)
fidget(22,7);  // call with bearing diameter and height in mm

module fidget(d, h)
{
r=d/2;
r3 = r/3;
r8 = r38;
difference()
{
minkowski()
{
linear_extrude(height = .01, convexity = 4)
offset(-r3
4-h/2) offset(r34) forN(r8, 3) circle(r35);
sphere(h/2);
}
forN(r8, 3) cylinder(r=r, h=r, center=true);
cylinder(r=r, h=r, center=true);
}
}
module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0,
0]) children();

--
View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21638.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

here a nice and simple constructor: > offset(-15) offset(12) forN(r=26, N=3) circle(20); > module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0, > 0]) children(); WITH minkowski the code for the fidget is quite straight forward. 4 minute render time is not at all bad. > $fn=40; // use 10 for experiments, 40 for finals (4min) > fidget(22,7); // call with bearing diameter and height in mm > > module fidget(d, h) > { > r=d/2; > r3 = r/3; > r8 = r3*8; > difference() > { > minkowski() > { > linear_extrude(height = .01, convexity = 4) > offset(-r3*4-h/2) offset(r3*4) forN(r8, 3) circle(r3*5); > sphere(h/2); > } > forN(r8, 3) cylinder(r=r, h=r, center=true); > cylinder(r=r, h=r, center=true); > } > } > module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0, > 0]) children(); -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21638.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Mon, Jun 5, 2017 1:24 AM

Very clever use of offset that avoids the Apollonius circle computation.
However, except for the generation of the profile, your code is essentially
the same as the original spinner_solid and the running time should be about
the same.

2017-06-04 20:19 GMT-03:00 Parkinbot rudolf@parkinbot.com:

WITH minkowski the code for the fidget is quite straight forward. 4 minute
render time is not at all bad.

$fn=40;          // use 10 for experiments, 40 for finals (4min)
fidget(22,7);  // call with bearing diameter and height in mm

module fidget(d, h)
{
r=d/2;
r3 = r/3;
r8 = r38;
difference()
{
minkowski()
{
linear_extrude(height = .01, convexity = 4)
offset(-r3
4-h/2) offset(r34) forN(r8, 3) circle(r35);
sphere(h/2);
}
forN(r8, 3) cylinder(r=r, h=r, center=true);
cylinder(r=r, h=r, center=true);
}
}
module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0,
0]) children();

Very clever use of offset that avoids the Apollonius circle computation. However, except for the generation of the profile, your code is essentially the same as the original spinner_solid and the running time should be about the same. 2017-06-04 20:19 GMT-03:00 Parkinbot <rudolf@parkinbot.com>: > WITH minkowski the code for the fidget is quite straight forward. 4 minute > render time is not at all bad. > > > > $fn=40; // use 10 for experiments, 40 for finals (4min) > > fidget(22,7); // call with bearing diameter and height in mm > > > > module fidget(d, h) > > { > > r=d/2; > > r3 = r/3; > > r8 = r3*8; > > difference() > > { > > minkowski() > > { > > linear_extrude(height = .01, convexity = 4) > > offset(-r3*4-h/2) offset(r3*4) forN(r8, 3) circle(r3*5); > > sphere(h/2); > > } > > forN(r8, 3) cylinder(r=r, h=r, center=true); > > cylinder(r=r, h=r, center=true); > > } > > } > > module forN(r, N) for(i=[0:N-1]) rotate([0,0,i*360/N]) translate([r, 0, > > 0]) children(); > >
P
Parkinbot
Mon, Jun 5, 2017 9:30 AM

If you use the constructor with a circle you can even omit the first offset
and enlarge the circle radius of course.

offset(-r34-h/2) forN(r8, 3) circle(r39);

What a pity that we don't get hands on the coordinates  ...

--
View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21641.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

If you use the constructor with a circle you can even omit the first offset and enlarge the circle radius of course. > offset(-r3*4-h/2) forN(r8, 3) circle(r3*9); What a pity that we don't get hands on the coordinates ... -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21641.html Sent from the OpenSCAD mailing list archive at Nabble.com.
IO
Ian Oliver
Mon, Jun 5, 2017 11:53 AM

On 2017-06-05 10:30, Parkinbot wrote:

What a pity that we don't get hands on the coordinates  ...

I've started creating lots of objects with functions that return points
(some my own, some using shapes and transform from SCAD utils) for
exactly this reason, and because I get rounding almost for free.

For instance, this function gives me the points for a rounded rectangle,
and I call it from a RoundedBox function (1) that uses similar loops to
round in the other dimensions. Throw the points into Skin () and the job
is done.

function RoundedRect (xsize=10, ysize=10, r=1, fa=$fa) = [
let (xo=(xsize/2)-r,yo=(ysize/2)-r)
for (a = [0: fa : 360-1]) [cos(a)*r + xo * sign(cos(a)), sin(a)*r +
yo * sign(sin(a))]
];

(1) - I'd supply the code but I haven't made generic yet and just have
one for my rather special case.

On 2017-06-05 10:30, Parkinbot wrote: > What a pity that we don't get hands on the coordinates ... I've started creating lots of objects with functions that return points (some my own, some using shapes and transform from SCAD utils) for exactly this reason, and because I get rounding almost for free. For instance, this function gives me the points for a rounded rectangle, and I call it from a RoundedBox function (1) that uses similar loops to round in the other dimensions. Throw the points into Skin () and the job is done. function RoundedRect (xsize=10, ysize=10, r=1, fa=$fa) = [ let (xo=(xsize/2)-r,yo=(ysize/2)-r) for (a = [0: fa : 360-1]) [cos(a)*r + xo * sign(cos(a)), sin(a)*r + yo * sign(sin(a))] ]; (1) - I'd supply the code but I haven't made generic yet and just have one for my rather special case.
C
caterpillar
Mon, Jun 5, 2017 12:46 PM

For the same reason, I also created several 2D shapes in my library :)

  • shape_taiwan
  • shape_arc
  • shape_pie
  • shape_ellipse
  • shape_square
  • shape_trapezium
  • shape_cyclicpolygon
  • shape_pentagram
  • shape_superformula
  • shape_glued2circles
  • shape_path_extend

http://openhome.cc

View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21643.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

For the same reason, I also created several 2D shapes in my library :) - shape_taiwan - shape_arc - shape_pie - shape_ellipse - shape_square - shape_trapezium - shape_cyclicpolygon - shape_pentagram - shape_superformula - shape_glued2circles - shape_path_extend ----- http://openhome.cc -- View this message in context: http://forum.openscad.org/Rounding-convex-edges-without-minkowski-tp21621p21643.html Sent from the OpenSCAD mailing list archive at Nabble.com.