Solver SSS Triangle Solver 3 sides
Algebra
->
Triangles
-> Solver SSS Triangle Solver 3 sides
Log On
Geometry: Triangles
Geometry
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of ' SSS Triangle Solver 3 sides'
This Solver ( SSS Triangle Solver 3 sides)
was created by by
tomlaidlaw(14)
:
View Source
,
Show
,
Put on YOUR site
About tomlaidlaw
:
74 year old man interested in mathematical recreations.
==section input <img src=http://tomlaidlaw.com/goatandsilo/circum.gif> Input the following side lengths of the triangle: a = *[input s1=2],b = *[input s2=3]and c = *[input s3=4] Find the Angles, Area, incircle radius, circumcircle radius, and altitudes, (with formulas). ==section solution perl my $d1 = $s1 +$s2; my $d2 = $s2 +$s3; my $d3 = $s3 +$s1; if($s1==0 || $s2==0 || $s3==0) { print " This is not a Triangle because atleast one of the side length is equal to zero. Please enter another set of values for a,b and c."; } elsif($d1==$s3 || $d2==$s1 || $d3==$s2) { print " This is not a Triangle because sum of two sides length is equal to the third side length. Please enter another set of values for a,b and c."; } else { if(($s1+$s2<$s3) || ($s2+$s3<$s1) || ($s1+$s3<$s2) ) { print " These sides do not form a triangle. Please enter another set of values for a,b and c. "; } else { print "Use Heron's Formula for Area: First calculate s=(a+b+c)/2, then: <img src=http://tomlaidlaw.com/goatandsilo/herons-formula.gif> Use the Law of Cosines for the angles: <img src=http://tomlaidlaw.com/goatandsilo/img36.gif>"; my $s = 1/2*($s1+$s2+$s3); my $K=sqrt($s*($s-$s1)*($s-$s2)*($s-$s3)); my $Kr=sprintf("%.3f", $K); my $A1=(($s2*$s2+$s3*$s3-$s1*$s1)/(2*$s2*$s3)); my $A2=atan2(sqrt(1-$A1*$A1),$A1); my $A2r=sprintf("%.3f",$A2); my $A=$A2*180/3.14159; my $Ar=sprintf("%.3f",$A); my $B1=(($s1*$s1+$s3*$s3-$s2*$s2)/(2*$s1*$s3)); my $B2=atan2(sqrt(1-$B1*$B1),$B1); my $B2r=sprintf("%.3f",$B2); my $B=$B2*180/3.14159; my $Br=sprintf("%.3f",$B); my $C1=(($s2*$s2+$s1*$s1-$s3*$s3)/(2*$s2*$s1)); my $C2=atan2(sqrt(1-$C1*$C1),$C1); my $C2r=sprintf("%.3f",$C2); my $C=$C2*180/3.14159; my $Cr=sprintf("%.3f", $C); my $R=.5*$s1/sin($A2); my $Rr=sprintf("%.3f", $R); my $r=2*$K/($s*2); my $rr=sprintf("%.3f", $r); my $ha=$s3*sin($B2); my $har=sprintf("%.3f", $ha); my $hb=$s1*sin($C2); my $hbr=sprintf("%.3f", $hb); my $hc=$s2*sin($A2); my $hcr=sprintf("%.3f", $hc); print " side a = $s1 side b = $s2 side c = $s3 AngleA = $Ar degrees or $A2r radians AngleB = $Br degrees or $B2r radians AngleC = $Cr degrees or $C2r radians Area K = $Kr Circumcircle Radius = $Rr __(R = .5a/sinA) incircle radius = $rr __(r = 2K/(a+b+c)) height over side a = $har __(ha = csinB) height over side b = $hbr __(hb = asinC) height over side c = $hcr __(hc = bsinA) Thanks to hummingbird for the use of his solver. Thanks to Wolfram Math World for the triangle graphic. Tom Laidlaw " ; } } ==section output K, ==section check s1=4 s2=3 s3=5 a=3.464101615