discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fwd: Re: help with maths

RW
Raymond West
Sun, Jan 23, 2022 5:43 PM

Thanks for your replies. I used https://arachnoid.com/polysolve/ and,
got a reasonable curve, and adjusted some of my points to fit.

I have often used, in the past (and also in the future), a sort of
cruciform shape to round off corners, along the lines of the following
example code. I extrude the 2d and rotate/translate as necessary to line
up with the edges of the object I want to round off. It is simple to
apply, as only need to translate the 'shave' to the appropriate edge.

// square rounded

rd = 3; // rounding radius

module shave(v){
difference(){
   square(2*v,true);
     translate ([-v,-v])circle (v);
     translate ([-v,v])circle (v);
     translate ([v,-v])circle (v);
     translate ([v,v])circle (v);
}
}

$fn=80;
shave(rd);

difference(){
translate([12,0,0]) square (15,true);
    translate ([12+(15/2),-15/2,0])
    shave(rd);
}

Now the recent conversation wrt rounding hex corners made me think I
could extend the same concept, which the following code sort of does,
but for any shape between a pentagon and an hendecagon.

More than 11 sides, the curve runs adrift, and it can take ages to
render anyway. Using this method, it is easy to select only some of the
corners, individually, or as shown below. Of course, this method is not
exactly pure or precise, but it's good enough, in many instances. (I've
commented out my 'empirical' code, so the resulting code would be
relatively  succinct.

// hexagon round

od = 20; //outside diameter of polygon
rd = 20; // rounding diameter
ns = 7; //number of sides must be between 5 and 11 inclusive
skip = 1; // skip corner rounding, 0 for rounding all corners

///////////////////////////////////////////////////////////////////
sa=skip+1;

module hexround(p){
   translate ([p,0,0])
       circle(p/2);
}
module allround(p){  // this could be better, maybe use angle
       rotate([0,180,0])
    intersection(){
          circle(p/1.6); //why 1.6 for hex cutoff? looks ok for others too
    difference(){
      circle(p);
        for (j= [0:360/ns:360-(360/ns)]){
      rotate([0,0,j])hexround(p);
     }
 }
        }
 }

module roundoff(d,p){

    /*
https://arachnoid.com/polysolve/

    f(x) =  4.1957142857141934e+000 * x^0
     + -4.3292857142854529e-001 * x^1
     +  2.2499999999998251e-002 * x^2
     === 2.25nsns -4.33ns +4.2
     /
    os= (0.0225
ns
ns) - (0.433*ns) +4.2;
   // echo(os);
    translate([d+(p/os),0,0 ])
    // following empirically derived positions - looks good enough
    //  translate([d+(p/2.6),0,0 ]) // why 2.6 for pentagon
     // translate([d+(p/2.4),0,0 ]) // why 2.35 for hexagon
   // translate([d+(p/2.26),0,0 ]) // 2.26 for heptagon
    //  translate([d+(p/2.18),0,0 ]) // 2.18 for octagon
    //   translate([d+(p/2.13),0,0 ]) // 2.13 for nonagon
    //  translate([d+(p/2.1),0,0 ]) // 2.11 for decagon
   #  allround(p);
 }

module roundhex(d,p){
    difference(){
      circle (d,$fn=ns);
        for (j= [0:360/(ns/sa):360-(360/(ns/sa))]){ // or individually
select corners
          rotate([0,0,j])roundoff(d,p);
        }
}
}

$fn=80;
roundhex(od,rd);

///////////////////

whether I can do a more generic result, from  triangles upwards, I'm not
sure if it is worth the effort.

Best wishes,

Ray

On 23/01/2022 15:16, Hans L wrote:

Here is one that seems decent:
https://arachnoid.com/polysolve/

Some example search terms:
polynomial best fit calculator
polynomial regression
curve fitting
etc.

On Sun, Jan 23, 2022 at 8:48 AM Raymond West raywest@raywest.com wrote:

 Hi,

 I have the following points on a graph of X,Y, derived
 empirically, but
 I would like to have the formula for their relationship. They seem to
 lie on a reasonable curve, bearing in mind the Y values were
 empirically
 derived, to not many decimal places.

 [5,2.6],[6,2.35],[7,2.26],[8,2.18],[9,2.13],[10,2.1]

 I was hoping that there would be a web site somewhere, where i could
 enter the x/y values, and out would pop the formula, but so far not
 found one. It was a long time ago, if ever, when I had to derive
 polynomial formulae. Any help appreciated.

 Best wishes,

 Ray

 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

Thanks for your replies. I used https://arachnoid.com/polysolve/ and, got a reasonable curve, and adjusted some of my points to fit. I have often used, in the past (and also in the future), a sort of cruciform shape to round off corners, along the lines of the following example code. I extrude the 2d and rotate/translate as necessary to line up with the edges of the object I want to round off. It is simple to apply, as only need to translate the 'shave' to the appropriate edge. // square rounded rd = 3; // rounding radius module shave(v){ difference(){    square(2*v,true);      translate ([-v,-v])circle (v);      translate ([-v,v])circle (v);      translate ([v,-v])circle (v);      translate ([v,v])circle (v); } } $fn=80; shave(rd); difference(){ translate([12,0,0]) square (15,true);     translate ([12+(15/2),-15/2,0])     shave(rd); } Now the recent conversation wrt rounding hex corners made me think I could extend the same concept, which the following code sort of does, but for any shape between a pentagon and an hendecagon. More than 11 sides, the curve runs adrift, and it can take ages to render anyway. Using this method, it is easy to select only some of the corners, individually, or as shown below. Of course, this method is not exactly pure or precise, but it's good enough, in many instances. (I've commented out my 'empirical' code, so the resulting code would be relatively  succinct. // hexagon round od = 20; //outside diameter of polygon rd = 20; // rounding diameter ns = 7; //number of sides must be between 5 and 11 inclusive skip = 1; // skip corner rounding, 0 for rounding all corners /////////////////////////////////////////////////////////////////// sa=skip+1; module hexround(p){    translate ([p,0,0])        circle(p/2); } module allround(p){  // this could be better, maybe use angle        rotate([0,180,0])     intersection(){           circle(p/1.6); //why 1.6 for hex cutoff? looks ok for others too     difference(){       circle(p);         for (j= [0:360/ns:360-(360/ns)]){       rotate([0,0,j])hexround(p);      }  }         }  } module roundoff(d,p){     /* https://arachnoid.com/polysolve/     f(x) =  4.1957142857141934e+000 * x^0      + -4.3292857142854529e-001 * x^1      +  2.2499999999998251e-002 * x^2      === 2.25*ns*ns -4.33*ns +4.2      */     os= (0.0225*ns*ns) - (0.433*ns) +4.2;    // echo(os);     translate([d+(p/os),0,0 ])     // following empirically derived positions - looks good enough     //  translate([d+(p/2.6),0,0 ]) // why 2.6 for pentagon      // translate([d+(p/2.4),0,0 ]) // why 2.35 for hexagon    // translate([d+(p/2.26),0,0 ]) // 2.26 for heptagon     //  translate([d+(p/2.18),0,0 ]) // 2.18 for octagon     //   translate([d+(p/2.13),0,0 ]) // 2.13 for nonagon     //  translate([d+(p/2.1),0,0 ]) // 2.11 for decagon    #  allround(p);  } module roundhex(d,p){     difference(){       circle (d,$fn=ns);         for (j= [0:360/(ns/sa):360-(360/(ns/sa))]){ // or individually select corners           rotate([0,0,j])roundoff(d,p);         } } } $fn=80; roundhex(od,rd); /////////////////// whether I can do a more generic result, from  triangles upwards, I'm not sure if it is worth the effort. Best wishes, Ray On 23/01/2022 15:16, Hans L wrote: > Here is one that seems decent: > https://arachnoid.com/polysolve/ > > Some example search terms: > polynomial best fit calculator > polynomial regression > curve fitting > etc. > > On Sun, Jan 23, 2022 at 8:48 AM Raymond West <raywest@raywest.com> wrote: > > Hi, > > I have the following points on a graph of X,Y, derived > empirically, but > I would like to have the formula for their relationship. They seem to > lie on a reasonable curve, bearing in mind the Y values were > empirically > derived, to not many decimal places. > > [5,2.6],[6,2.35],[7,2.26],[8,2.18],[9,2.13],[10,2.1] > > I was hoping that there would be a web site somewhere, where i could > enter the x/y values, and out would pop the formula, but so far not > found one. It was a long time ago, if ever, when I had to derive > polynomial formulae. Any help appreciated. > > Best wishes, > > Ray > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Mon, Jan 24, 2022 1:46 AM

https://github.com/sprabhakar2006/openSCAD/blob/main/Screenshot%202022-01-24%20at%207.11.24%20AM.png

you can use google sheets for finding the equation

On Sun, 23 Jan 2022 at 23:13, Raymond West raywest@raywest.com wrote:

Thanks for your replies. I used https://arachnoid.com/polysolve/ and, got
a reasonable curve, and adjusted some of my points to fit.

I have often used, in the past (and also in the future), a sort of
cruciform shape to round off corners, along the lines of the following
example code. I extrude the 2d and rotate/translate as necessary to line up
with the edges of the object I want to round off. It is simple to apply, as
only need to translate the 'shave' to the appropriate edge.

// square rounded

rd = 3; // rounding radius

module shave(v){
difference(){
square(2*v,true);
translate ([-v,-v])circle (v);
translate ([-v,v])circle (v);
translate ([v,-v])circle (v);
translate ([v,v])circle (v);
}
}

$fn=80;
shave(rd);

difference(){
translate([12,0,0]) square (15,true);
translate ([12+(15/2),-15/2,0])
shave(rd);
}

Now the recent conversation wrt rounding hex corners made me think I could
extend the same concept, which the following code sort of does, but for any
shape between a pentagon and an hendecagon.

More than 11 sides, the curve runs adrift, and it can take ages to render
anyway. Using this method, it is easy to select only some of the corners,
individually, or as shown below. Of course, this method is not exactly pure
or precise, but it's good enough, in many instances. (I've commented out my
'empirical' code, so the resulting code would be relatively  succinct.

// hexagon round

od = 20; //outside diameter of polygon
rd = 20; // rounding diameter
ns = 7; //number of sides must be between 5 and 11 inclusive
skip = 1; // skip corner rounding, 0 for rounding all corners

///////////////////////////////////////////////////////////////////
sa=skip+1;

module hexround(p){
translate ([p,0,0])
circle(p/2);
}
module allround(p){  // this could be better, maybe use angle
rotate([0,180,0])
intersection(){
circle(p/1.6); //why 1.6 for hex cutoff? looks ok for others too
difference(){
circle(p);
for (j= [0:360/ns:360-(360/ns)]){
rotate([0,0,j])hexround(p);
}
}
}
}

module roundoff(d,p){

 /*
 https://arachnoid.com/polysolve/

 f(x) =  4.1957142857141934e+000 * x^0
  + -4.3292857142854529e-001 * x^1
  +  2.2499999999998251e-002 * x^2
  === 2.25*ns*ns -4.33*ns +4.2
  */
 os= (0.0225*ns*ns) - (0.433*ns) +4.2;
// echo(os);
 translate([d+(p/os),0,0 ])
 // following empirically derived positions - looks good enough
 //  translate([d+(p/2.6),0,0 ]) // why 2.6 for pentagon
  // translate([d+(p/2.4),0,0 ]) // why 2.35 for hexagon
// translate([d+(p/2.26),0,0 ]) // 2.26 for heptagon
 //  translate([d+(p/2.18),0,0 ]) // 2.18 for octagon
 //   translate([d+(p/2.13),0,0 ]) // 2.13 for nonagon
 //  translate([d+(p/2.1),0,0 ]) // 2.11 for decagon
#  allround(p);

}

module roundhex(d,p){
difference(){
circle (d,$fn=ns);
for (j= [0:360/(ns/sa):360-(360/(ns/sa))]){ // or individually
select corners
rotate([0,0,j])roundoff(d,p);
}
}
}

$fn=80;
roundhex(od,rd);

///////////////////

whether I can do a more generic result, from  triangles upwards, I'm not
sure if it is worth the effort.

Best wishes,

Ray

On 23/01/2022 15:16, Hans L wrote:

Here is one that seems decent:
https://arachnoid.com/polysolve/

Some example search terms:
polynomial best fit calculator
polynomial regression
curve fitting
etc.

On Sun, Jan 23, 2022 at 8:48 AM Raymond West raywest@raywest.com wrote:

Hi,

I have the following points on a graph of X,Y, derived empirically, but
I would like to have the formula for their relationship. They seem to
lie on a reasonable curve, bearing in mind the Y values were empirically
derived, to not many decimal places.

[5,2.6],[6,2.35],[7,2.26],[8,2.18],[9,2.13],[10,2.1]

I was hoping that there would be a web site somewhere, where i could
enter the x/y values, and out would pop the formula, but so far not
found one. It was a long time ago, if ever, when I had to derive
polynomial formulae. Any help appreciated.

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

https://github.com/sprabhakar2006/openSCAD/blob/main/Screenshot%202022-01-24%20at%207.11.24%20AM.png you can use google sheets for finding the equation On Sun, 23 Jan 2022 at 23:13, Raymond West <raywest@raywest.com> wrote: > Thanks for your replies. I used https://arachnoid.com/polysolve/ and, got > a reasonable curve, and adjusted some of my points to fit. > > I have often used, in the past (and also in the future), a sort of > cruciform shape to round off corners, along the lines of the following > example code. I extrude the 2d and rotate/translate as necessary to line up > with the edges of the object I want to round off. It is simple to apply, as > only need to translate the 'shave' to the appropriate edge. > > // square rounded > > rd = 3; // rounding radius > > module shave(v){ > difference(){ > square(2*v,true); > translate ([-v,-v])circle (v); > translate ([-v,v])circle (v); > translate ([v,-v])circle (v); > translate ([v,v])circle (v); > } > } > > $fn=80; > shave(rd); > > difference(){ > translate([12,0,0]) square (15,true); > translate ([12+(15/2),-15/2,0]) > shave(rd); > } > > Now the recent conversation wrt rounding hex corners made me think I could > extend the same concept, which the following code sort of does, but for any > shape between a pentagon and an hendecagon. > > More than 11 sides, the curve runs adrift, and it can take ages to render > anyway. Using this method, it is easy to select only some of the corners, > individually, or as shown below. Of course, this method is not exactly pure > or precise, but it's good enough, in many instances. (I've commented out my > 'empirical' code, so the resulting code would be relatively succinct. > > > // hexagon round > > od = 20; //outside diameter of polygon > rd = 20; // rounding diameter > ns = 7; //number of sides must be between 5 and 11 inclusive > skip = 1; // skip corner rounding, 0 for rounding all corners > > /////////////////////////////////////////////////////////////////// > sa=skip+1; > > module hexround(p){ > translate ([p,0,0]) > circle(p/2); > } > module allround(p){ // this could be better, maybe use angle > rotate([0,180,0]) > intersection(){ > circle(p/1.6); //why 1.6 for hex cutoff? looks ok for others too > difference(){ > circle(p); > for (j= [0:360/ns:360-(360/ns)]){ > rotate([0,0,j])hexround(p); > } > } > } > } > > module roundoff(d,p){ > > /* > https://arachnoid.com/polysolve/ > > f(x) = 4.1957142857141934e+000 * x^0 > + -4.3292857142854529e-001 * x^1 > + 2.2499999999998251e-002 * x^2 > === 2.25*ns*ns -4.33*ns +4.2 > */ > os= (0.0225*ns*ns) - (0.433*ns) +4.2; > // echo(os); > translate([d+(p/os),0,0 ]) > // following empirically derived positions - looks good enough > // translate([d+(p/2.6),0,0 ]) // why 2.6 for pentagon > // translate([d+(p/2.4),0,0 ]) // why 2.35 for hexagon > // translate([d+(p/2.26),0,0 ]) // 2.26 for heptagon > // translate([d+(p/2.18),0,0 ]) // 2.18 for octagon > // translate([d+(p/2.13),0,0 ]) // 2.13 for nonagon > // translate([d+(p/2.1),0,0 ]) // 2.11 for decagon > # allround(p); > } > > module roundhex(d,p){ > difference(){ > circle (d,$fn=ns); > for (j= [0:360/(ns/sa):360-(360/(ns/sa))]){ // or individually > select corners > rotate([0,0,j])roundoff(d,p); > } > } > } > > > $fn=80; > roundhex(od,rd); > > /////////////////// > > whether I can do a more generic result, from triangles upwards, I'm not > sure if it is worth the effort. > > Best wishes, > > Ray > > > On 23/01/2022 15:16, Hans L wrote: > > Here is one that seems decent: > https://arachnoid.com/polysolve/ > > Some example search terms: > polynomial best fit calculator > polynomial regression > curve fitting > etc. > > On Sun, Jan 23, 2022 at 8:48 AM Raymond West <raywest@raywest.com> wrote: > >> Hi, >> >> I have the following points on a graph of X,Y, derived empirically, but >> I would like to have the formula for their relationship. They seem to >> lie on a reasonable curve, bearing in mind the Y values were empirically >> derived, to not many decimal places. >> >> [5,2.6],[6,2.35],[7,2.26],[8,2.18],[9,2.13],[10,2.1] >> >> I was hoping that there would be a web site somewhere, where i could >> enter the x/y values, and out would pop the formula, but so far not >> found one. It was a long time ago, if ever, when I had to derive >> polynomial formulae. Any help appreciated. >> >> Best wishes, >> >> Ray >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >