randomTriangleWithSides() rand( 3 ) MAIN[ 1 ][ HIDDEN ] MAIN[ 1 ].slice( 0, HIDDEN ).concat( MAIN[ 1 ].slice( HIDDEN + 1 ) ) roundTo( 1, parseFloat( KNOWN[ 0 ] ) + parseFloat( KNOWN[ 1 ] ) ) roundTo( 1, abs( KNOWN[ 0 ] - KNOWN[ 1 ] ) )
What is the range of possible sizes for side x?
init({ range: [ [ -1, 10 ], [ -7.5, 1 ] ] }) var tr = new Triangle( [ 3, -6.5 ], MAIN[ 0 ], 5, { "sides" : [ HIDDEN !== 2 ? MAIN[ 1 ][ 2 ] : "x", HIDDEN !== 0 ? MAIN[ 1 ][ 0 ] : "x", HIDDEN !== 1 ? MAIN[ 1 ][ 1 ] : "x" ] } ); tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); tr.draw(); tr.drawLabels();

MIN < x < MAX

two exact decimals, like 0.75

The triangle inequality theorem states that any side of a triangle is always shorter than the sum of the other two sides.

Therefore the the third side must be less than KNOWN[ 0 ] + KNOWN[ 1 ] = MAX

By the same theorem, the third side must be also larger than the difference between the other two sides.

Therefore the third side must be larger than KNOWN[0] < KNOWN[1] ? KNOWN[1] : KNOWN[0] - KNOWN[0] < KNOWN[1] ? KNOWN[0] : KNOWN[1] = MIN

So MIN < x < MAX

randomTriangleWithSides() ( randRange( 0, 1 ) === 0 )
Can this triangle exist?
init({ range: [ [-1, 10 ], [ -7.5, 1 ] ] }) if( !POSSIBLE ){ var side = randRange( 0, 2 ); var sideValue = ( parseFloat( MAIN[ 1 ][ ( side + 1 ) % 3 ] ) + parseFloat( MAIN[ 1 ][ ( side + 2 ) % 3 ] ) + randRange( 1, 3 ) ).toFixed( 1 ); MAIN[ 1 ][ side ] = sideValue; } var tr = new Triangle( [ 3, -6.9 ], MAIN[ 0 ], 5, { "sides" : [ MAIN[ 1 ][ 2 ], MAIN[ 1 ][ 0 ], MAIN[ 1 ][ 1 ] ] } ); tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] ); tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] ); tr.draw(); tr.drawLabels();
POSSIBLE ? "Yes" : "No"
  • Yes
  • No

Triangle inequality theorem states that a side must be smaller than the sum of the other two sides.

Let's check for all three sides:

MAIN[ 1 ][ i ] + MAIN[ 1 ][ ( i + 1 ) % 3 ] = ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 )

MAIN[ 1 ][ ( i + 2 ) % 3 ] is not smaller than ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 ) so the theorem does not holdholds.

All three sides conform to the inequality theorem, so this triangle can exist.

Not all three sides conform to the inequality theorem, so this triangle cannot exist.