After my last post I needed a way to find an angle after using the scale function of linear_extrude. I went to use the protractor from post #50 and it was unfinished and pretty hard to use so I decided to make some improvements. Once again there is some work to do but I have added a trig triangle calculator and will be adding a lot more functionality as I get time and figure out how I want it to work.
I used linear_extrude scale to make the sides of the pan angle out but was having a difficult time figuring out the angle I needed to use to adjust the ridges so I made a calculator that will calculate the angle automatically
First I saved just the ring of the pan to an stl file:
Then I imported it into my calculator:
Now I can adjust the settings until they line up and this will give me the right angle I need.
Here is the code for the calculator:
//
/*[Extrude Scale Angle Calculator]*/
Diameter=254;//[50:.01:400]
Scale=1;//[-1.00:.001:10.00]
Height=10;//[1.00:.001:100.00]
Shape=100;//[3:1:100]
linear_extrude(Height,scale=Scale)
circle(Diameter/2,$fn=Shape);
/*[Hidden]*/
$fa=$preview? 2:1;;
$fs=$preview?.5:.1;;
Radius=Diameter/2;
Opposite=Radius*Scale-Radius;
Adjacent=Height;
Hypotenuse=sqrt(Opposite^2+Adjacent^2);
Angle_h=((Opposite*Adjacent)/Hypotenuse);
Angle_a=asin(Opposite/Hypotenuse);
Angle_b=asin(Adjacent/Hypotenuse);
echo(Hypotenuse=(Hypotenuse));
echo(Angle_a=(Angle_a));
echo(Angle_b=(Angle_b));
echo(Angle_h=(Angle_h));
echo(Opposite=(Opposite));
echo(Adjacent=(Adjacent));
echo(Scale);
#import("/home/none4/Desktop/gold pan.stl");
Just delete the path in that last import line and insert your own to try it out.
Once I knew I need an angle of 64.712 I imported the pan into my protractor code to test it to see how accurate it is:
I set the stl import to be transparent using # so it would be easy to see where the edge of the object was.
It looks like the protractor and the trig calculator are spot on with what my extrude scale calculator was calculating.
Here is the updated protractor code:
//
/*[STL Import]*/
Show_STL=false;
Path_to_STL_file="File.stl";
Move_STL_X=0;//[-400:.01:400]
Move_STL_Y=0;//[-400:.01:400]
Move_STL_Z=0;//[-400:.01:400]
Rotate_STL_X=0;//[-400:.01:400]
Rotate_STL_Y=0;//[-400:.01:400]
Rotate_STL_Z=0;//[-400:.01:400]
/*[Protractor]*/
Show_Protractor = true;
Protractor_diameter = 400;//[.1:.1:1000]
Rotate_angle = 0; // [-360.00:.01:360.00]
/*[Trig Calculator]*/
Show_Trig_Triangle=true;
Adjacent=50;//[1:.01:1000]
Opposite=50;//[1:.01:1000]
/*[Angle Text]*/
text1=str(Rotate_angle);
length1=len(text1);
/*[Formulas]*/
Radius = Protractor_diameter/2;
Area = PI*(Radius^2);
Degrees = Rotate_angle;
Arc_length = Degrees*(PI/180)*Radius;
Arc = str(Arc_length);
T_Opposite=Opposite;
T_Adjacent=Adjacent;
Hypotenuse=sqrt(Opposite^2+Adjacent^2);
Angle_h=((Opposite*Adjacent)/Hypotenuse);
Angle_a=asin(Opposite/Hypotenuse);
Angle_b=asin(Adjacent/Hypotenuse);
/*[Trig Text]*/
text2=str(Angle_b);
length2=len(text2);
text3=str(Angle_a);
length3=len(text3);
text4=str(Opposite);
length4=len(text4);
text5=str(Adjacent);
length5=len(text5);
/*[Hidden]*/
$fa=$preview? 2:1;;
$fs=$preview?.5:.1;;
module Protractor(){
if(Show_Protractor){
rotate([0,Rotate_angle,0])
rotate([90,0,0])
translate([0,-Protractor_diameter/2,0])
color("yellow",.8)
cube([2,Protractor_diameter,14]);
rotate([0,Rotate_angle,0])
rotate([90,0,0])
color("royalblue",.8)
linear_extrude(10)
circle(Protractor_diameter/2,$fn=200);
rotate([0,Rotate_angle,0])
rotate([90,0,0])
color("grey")
linear_extrude(8)
circle(Protractor_diameter/2+30,$fn=200);
}}
module Trig_triangle(){
rotate([90,0,180])
translate([-Adjacent,0,-16])
resize([T_Adjacent,T_Opposite,24])
linear_extrude(16)
polygon(points=[[0,0],[10,0],[0,10],[0,0],[80,0],[0,80]],
paths=[[0,0,0],[3,4,5]],convexity=10);
}
module Protractor_text(){
rotate([0,Rotate_angle,0])
translate([0,12,Protractor_diameter/2+4])
rotate([90,0,0])
linear_extrude(24)
text(str(text1),size=20,font ="",
halign="center", valign="bottom",spacing =1,
direction="ltr",$fn=100);
}
module Trig_triangle_text(){
translate([8,-12,-12])
rotate([90,0,0])
color("white",.01)
linear_extrude(2)
text(str(text2),size=10,font ="",
halign="left", valign="bottom",spacing =1,
direction="ltr",$fn=100);
translate([Adjacent+3,-10,Opposite-12])
rotate([90,0,0])
linear_extrude(2)
text(str(text3),size=10,font ="",
halign="left", valign="bottom",spacing =1,
direction="ltr",$fn=100);
translate([Adjacent-12,-12,Opposite/2])
rotate([450,90,0])
linear_extrude(2)
text(str(text4),size=10,font ="",
halign="center", valign="bottom",spacing =1,
direction="ltr",$fn=100);
translate([Adjacent/2,-12,5])
rotate([90,0,0])
color("white",.01)
linear_extrude(2)
text(str(text5),size=10,font ="",
halign="center", valign="bottom",spacing =1,
direction="ltr",$fn=100);
}
module STL_import(){
rotate([Rotate_STL_X,Rotate_STL_Y,Rotate_STL_Z])
import(Path_to_STL_file,center=true);
}
if(Show_Trig_Triangle){
difference(){
translate([0,4,0])
color("skyblue",.4)
Trig_triangle();
Protractor();
}
color("red")
Trig_triangle_text();
}
if(Show_Protractor){
render()
Protractor();
Protractor_text();
mirror([0,1,0])
Protractor();
}
if(Show_STL){
translate([Move_STL_X,Move_STL_Y,Move_STL_Z])
rotate([Rotate_STL_X,Rotate_STL_Y,Rotate_STL_Z])
color("red",.5)
STL_import();
}
echo(Hypotenuse=(Hypotenuse));
echo(Angle_a=(Angle_a));
echo(Angle_b=(Angle_b));
echo(Angle_h=(Angle_h));
echo(Opposite=(Opposite));
echo(Adjacent=(Adjacent));
Now it will be easy to add some text that shows sine,cosine, area etc.
I'm sure I probably missed something or made some errors I didn't catch because I always seem to catch mistakes a day or two later so I will be updating this post as I find them.