randomTriangleAngles.triangle()
[]
[]
[]
randRange( 3, 7 ) + random()
AREA * AREA
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, {} );
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" : trA.niceSideLengths };
trA.drawLabels();
SIDES = trA.niceSideLengths;
S = roundTo(2, ( ( SIDES[ 0 ] + SIDES[ 1 ] + SIDES[ 2 ] ) / 2 ));
ANS = localeToFixed(sqrt(S *( S -SIDES[ 0 ] ) * ( S - SIDES[ 1 ] ) * ( S - SIDES[ 2 ] ) ), 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{ SIDES[ 0 ] + SIDES[ 1 ] + SIDES[ 2 ] }{ 2 }
s = \dfrac{ localeToFixed( SIDES[ 0 ] + SIDES[ 1 ] + SIDES[ 2 ], 1) }{ 2 }
s = S
A = \sqrt{ S \cdot ( S - SIDES[ 0 ] ) \cdot ( S - SIDES[ 1 ] ) \cdot ( S - SIDES[ 2 ] ) }
A = \sqrt{ S \cdot localeToFixed(S - SIDES[ 0 ], 2) \cdot localeToFixed( S - SIDES[ 1 ], 2 ) \cdot localeToFixed( S - SIDES[ 2 ], 2 ) }
A = ANS