discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Math help

J
jjubenv
Mon, Jun 7, 2021 4:53 PM

Hi All,

I am creating a digital design for a step stool to get into our camper
trailer. It has splayed legs at each corner that are angled out in 2
direction by 15 degrees.  It has an apron to wrap around the outside of the
legs and I'm having issues getting the apron mitered/beveled at the correct
spot (at both ends of the part). I'm pretty certain it's my math at issue
and not with OpenSCAD.

Below is the code, I'd like to eliminate the fudge_factor variable by
learning the proper math for the translation.  I'd don't know what this
technique is called, so it's hard to search for answers/examples.  I'm all
for approaching it a better way if there is a best practice that I don't
know about.

// OpenSCAD version 2021.01 (git 41f58fe) Linux appimage
//
// Apron part around a step stool with splayed out legs

module apron() {
a_length = 22;    // Length of apron part
a_width = 3;      // Width of apron part
a_thick = 0.75;  // Thickness of apron part

a_side_angle = 90-15;     // 15 degree angle
a_corner_angle = 360/4;   // 90 degree corners (4 sides)

//Part features: 
//    a miter on the end of the wide face 
//    a bevel on the end of the miter

// Strategy: use a rectangle on each end to cut out (difference) the

miter and bevel

// compound angle formula to adjust the 15 degree miter
a_miter = atan( cos(a_side_angle) * tan(a_corner_angle/2) );

// compound angle formula to adjust the 45 degree bevel
a_bevel = asin( sin(a_side_angle) * sin(a_corner_angle/2) );

echo("a_miter=", a_miter);
echo("a_bevel=", a_bevel);

// fudge_factor: positions the blocks so the sides meet at the corner
// otherwise the sides overlap.
// I'd like to get rid of this.
*fudge_factor* = 0.041;

difference() {
    difference() {
        // the apron part
        translate([-a_length/2, -a_width/2, 0])  // move origin to

center of part
linear_extrude(height=a_thick, center=true, $fn=10)
polygon(
points=[
[0,0],
[a_widthtan(a_miter), a_width],
[a_length-a_width
tan(a_miter), a_width],
[a_length, 0]
]);
// position the block at the right end of the part and
// subtract it
translate([a_length/2 - fudge_factor,0,0])
rotate([0,0,a_miter])
rotate([0,-a_bevel,0])
cube([1,4,3], true);
}
// position the block at the left end of the part and
// subtract it
translate([-a_length/2 + fudge_factor,0,0])
rotate([0,0,-a_miter])
rotate([0,a_bevel,0])
cube([1,4,3], true);
}
}

//apron();

color("yellow")
translate([11-0.75,0,0])
rotate([270+15,0,0])
apron();

color("red")
translate([0,11-0.75,0])
rotate([270+15,0,270])
apron();
// End

Regards,
Jake

--
Sent from: http://forum.openscad.org/

Hi All, I am creating a digital design for a step stool to get into our camper trailer. It has splayed legs at each corner that are angled out in 2 direction by 15 degrees. It has an apron to wrap around the outside of the legs and I'm having issues getting the apron mitered/beveled at the correct spot (at both ends of the part). I'm pretty certain it's my math at issue and not with OpenSCAD. Below is the code, I'd like to eliminate the *fudge_factor* variable by learning the proper math for the translation. I'd don't know what this technique is called, so it's hard to search for answers/examples. I'm all for approaching it a better way if there is a best practice that I don't know about. // OpenSCAD version 2021.01 (git 41f58fe) Linux appimage // // Apron part around a step stool with splayed out legs module apron() { a_length = 22; // Length of apron part a_width = 3; // Width of apron part a_thick = 0.75; // Thickness of apron part a_side_angle = 90-15; // 15 degree angle a_corner_angle = 360/4; // 90 degree corners (4 sides) //Part features: // a miter on the end of the wide face // a bevel on the end of the miter // Strategy: use a rectangle on each end to cut out (difference) the miter and bevel // compound angle formula to adjust the 15 degree miter a_miter = atan( cos(a_side_angle) * tan(a_corner_angle/2) ); // compound angle formula to adjust the 45 degree bevel a_bevel = asin( sin(a_side_angle) * sin(a_corner_angle/2) ); echo("a_miter=", a_miter); echo("a_bevel=", a_bevel); // fudge_factor: positions the blocks so the sides meet at the corner // otherwise the sides overlap. // I'd like to get rid of this. *fudge_factor* = 0.041; difference() { difference() { // the apron part translate([-a_length/2, -a_width/2, 0]) // move origin to center of part linear_extrude(height=a_thick, center=true, $fn=10) polygon( points=[ [0,0], [a_width*tan(a_miter), a_width], [a_length-a_width*tan(a_miter), a_width], [a_length, 0] ]); // position the block at the right end of the part and // subtract it translate([a_length/2 - *fudge_factor*,0,0]) rotate([0,0,a_miter]) rotate([0,-a_bevel,0]) cube([1,4,3], true); } // position the block at the left end of the part and // subtract it translate([-a_length/2 + *fudge_factor*,0,0]) rotate([0,0,-a_miter]) rotate([0,a_bevel,0]) cube([1,4,3], true); } } //apron(); color("yellow") translate([11-0.75,0,0]) rotate([270+15,0,0]) apron(); color("red") translate([0,11-0.75,0]) rotate([270+15,0,270]) apron(); // End Regards, Jake -- Sent from: http://forum.openscad.org/
A
adrianv
Mon, Jun 7, 2021 10:09 PM

Are you trying to work out the math or create the model?  Because I would
construct the model in a math-free way.  Personally I think it's always
better to construct models without the explicit use of math.  (The computer
should do the math.)

a_length =22;
a_width=3;
a_thick=0.75;
a_side_angle = 15;

module apron_part()
{
intersection(){
rotate(-45) cube(a_length2);
translate([a_length/2,0,0])rotate([0,-a_side_angle,0])
cube([a_thick, 2
a_length, a_width], center=true);
}
}

apron_part();
rotate(90)color("red")apron_part();

jjubenv wrote

Hi All,

I am creating a digital design for a step stool to get into our camper
trailer. It has splayed legs at each corner that are angled out in 2
direction by 15 degrees.  It has an apron to wrap around the outside of
the
legs and I'm having issues getting the apron mitered/beveled at the
correct
spot (at both ends of the part). I'm pretty certain it's my math at issue
and not with OpenSCAD.

Below is the code, I'd like to eliminate the fudge_factor variable by
learning the proper math for the translation.  I'd don't know what this
technique is called, so it's hard to search for answers/examples.  I'm all
for approaching it a better way if there is a best practice that I don't
know about.

// OpenSCAD version 2021.01 (git 41f58fe) Linux appimage
//
// Apron part around a step stool with splayed out legs

module apron() {
a_length = 22;    // Length of apron part
a_width = 3;      // Width of apron part
a_thick = 0.75;  // Thickness of apron part

 a_side_angle = 90-15;     // 15 degree angle
 a_corner_angle = 360/4;   // 90 degree corners (4 sides)
 
 //Part features: 
 //    a miter on the end of the wide face 
 //    a bevel on the end of the miter
 
 // Strategy: use a rectangle on each end to cut out (difference) the

miter and bevel

 // compound angle formula to adjust the 15 degree miter
 a_miter = atan( cos(a_side_angle) * tan(a_corner_angle/2) );
 
 // compound angle formula to adjust the 45 degree bevel
 a_bevel = asin( sin(a_side_angle) * sin(a_corner_angle/2) );

 echo("a_miter=", a_miter);
 echo("a_bevel=", a_bevel);
 
 // fudge_factor: positions the blocks so the sides meet at the corner
 // otherwise the sides overlap.
 // I'd like to get rid of this.
 *fudge_factor* = 0.041;
 
 difference() {
     difference() {
         // the apron part
         translate([-a_length/2, -a_width/2, 0])  // move origin to

center of part
linear_extrude(height=a_thick, center=true, $fn=10)
polygon(
points=[
[0,0],
[a_widthtan(a_miter), a_width],
[a_length-a_width
tan(a_miter), a_width],
[a_length, 0]
]);
// position the block at the right end of the part and
// subtract it
translate([a_length/2 - fudge_factor,0,0])
rotate([0,0,a_miter])
rotate([0,-a_bevel,0])
cube([1,4,3], true);
}
// position the block at the left end of the part and
// subtract it
translate([-a_length/2 + fudge_factor,0,0])
rotate([0,0,-a_miter])
rotate([0,a_bevel,0])
cube([1,4,3], true);
}
}

//apron();

color("yellow")
translate([11-0.75,0,0])
rotate([270+15,0,0])
apron();

color("red")
translate([0,11-0.75,0])
rotate([270+15,0,270])
apron();
// End

Regards,
Jake

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

Are you trying to work out the math or create the model? Because I would construct the model in a math-free way. Personally I think it's always better to construct models without the explicit use of math. (The computer should do the math.) a_length =22; a_width=3; a_thick=0.75; a_side_angle = 15; module apron_part() { intersection(){ rotate(-45) cube(a_length*2); translate([a_length/2,0,0])rotate([0,-a_side_angle,0]) cube([a_thick, 2*a_length, a_width], center=true); } } apron_part(); rotate(90)color("red")apron_part(); jjubenv wrote > Hi All, > > I am creating a digital design for a step stool to get into our camper > trailer. It has splayed legs at each corner that are angled out in 2 > direction by 15 degrees. It has an apron to wrap around the outside of > the > legs and I'm having issues getting the apron mitered/beveled at the > correct > spot (at both ends of the part). I'm pretty certain it's my math at issue > and not with OpenSCAD. > > Below is the code, I'd like to eliminate the *fudge_factor* variable by > learning the proper math for the translation. I'd don't know what this > technique is called, so it's hard to search for answers/examples. I'm all > for approaching it a better way if there is a best practice that I don't > know about. > > // OpenSCAD version 2021.01 (git 41f58fe) Linux appimage > // > // Apron part around a step stool with splayed out legs > > module apron() { > a_length = 22; // Length of apron part > a_width = 3; // Width of apron part > a_thick = 0.75; // Thickness of apron part > > a_side_angle = 90-15; // 15 degree angle > a_corner_angle = 360/4; // 90 degree corners (4 sides) > > //Part features: > // a miter on the end of the wide face > // a bevel on the end of the miter > > // Strategy: use a rectangle on each end to cut out (difference) the > miter and bevel > > // compound angle formula to adjust the 15 degree miter > a_miter = atan( cos(a_side_angle) * tan(a_corner_angle/2) ); > > // compound angle formula to adjust the 45 degree bevel > a_bevel = asin( sin(a_side_angle) * sin(a_corner_angle/2) ); > > echo("a_miter=", a_miter); > echo("a_bevel=", a_bevel); > > // fudge_factor: positions the blocks so the sides meet at the corner > // otherwise the sides overlap. > // I'd like to get rid of this. > *fudge_factor* = 0.041; > > difference() { > difference() { > // the apron part > translate([-a_length/2, -a_width/2, 0]) // move origin to > center of part > linear_extrude(height=a_thick, center=true, $fn=10) > polygon( > points=[ > [0,0], > [a_width*tan(a_miter), a_width], > [a_length-a_width*tan(a_miter), a_width], > [a_length, 0] > ]); > // position the block at the right end of the part and > // subtract it > translate([a_length/2 - *fudge_factor*,0,0]) > rotate([0,0,a_miter]) > rotate([0,-a_bevel,0]) > cube([1,4,3], true); > } > // position the block at the left end of the part and > // subtract it > translate([-a_length/2 + *fudge_factor*,0,0]) > rotate([0,0,-a_miter]) > rotate([0,a_bevel,0]) > cube([1,4,3], true); > } > } > > //apron(); > > color("yellow") > translate([11-0.75,0,0]) > rotate([270+15,0,0]) > apron(); > > color("red") > translate([0,11-0.75,0]) > rotate([270+15,0,270]) > apron(); > // End > > Regards, > Jake > > > > -- > Sent from: http://forum.openscad.org/ > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
J
jjubenv
Mon, Jun 7, 2021 11:49 PM

Your solution is so much simpler, I'm amazed.  Thanks so much.

Regards,
Jake

--
Sent from: http://forum.openscad.org/

Your solution is so much simpler, I'm amazed. Thanks so much. Regards, Jake -- Sent from: http://forum.openscad.org/