randomTriangleAngles.triangle()
[]
[]
[]
randRange( 3, 7 ) + random()
What is the area of this triangle? ( Round to two decimal places )
init({
range: [ [-1, 12 ], [ -7, 2.5 ] ]
})
var trA = new Triangle( [ 3, -3 ], ANGLES ,AREA, {} );
SIDES = trA.niceSideLengths;
trA.boxOut( [ [ [ -10, 2.3 ], [ 10, 2.3 ] ] ] , [ 0, -0.7 ] );
trA.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ] , [ 0.7, 0 ] );
trA.boxOut( [ [ [ 11.5, -10 ], [ 11.5, 10 ] ] ] , [ -0.7, 0 ] );
trA.draw();
trA.labels = { "sides" : [commafy(SIDES[0]), commafy(SIDES[1]), commafy(SIDES[2])] };
trA.drawLabels();
S = roundTo(2, ( ( SIDES[ 0 ] + SIDES[ 1 ] + SIDES[ 2 ] ) / 2 ));
ANS = roundTo(2, sqrt(S *( S -SIDES[ 0 ] ) * ( S - SIDES[ 1 ] ) * ( S - SIDES[ 2 ] ) ));
$( "#ans" ).html( ANS ) ;
We know all sides of this triangle, so we can use Heron's formula to calculate the area.
Heron's formula states that the area of a triangle A=\sqrt{s(s-a)(s-b)(s-c)}
s = \dfrac{ a + b + c }{ 2 }
s = \dfrac{ commafy(SIDES[0]) + commafy(SIDES[1]) + commafy(SIDES[2]) }{ 2 }
s = \dfrac{ localeToFixed( SIDES[ 0 ] + SIDES[ 1 ] + SIDES[ 2 ], 1) }{ 2 }
s = commafy(S)
A = \sqrt{ commafy(S) \cdot ( commafy(S) - commafy(SIDES[0]) ) \cdot ( commafy(S) - commafy(SIDES[1]) ) \cdot ( commafy(S) - commafy(SIDES[2]) ) }
A = \sqrt{ commafy(S) \cdot commafy(roundTo(2, S - SIDES[ 0 ])) \cdot commafy(roundTo(2, S - SIDES[ 1 ])) \cdot commafy(roundTo(2, S - SIDES[ 2 ])) }
A = commafy(ANS)