text: Program to find the Excenters of a Triangle | Function to calculate the distance between a pair of pos ; Function to calculate the coordinates of the excenters of a triangle ; Length of the sides of the triangle ; Stores the coordinates of the excenters of the triangle ; For I1 ; For I2 ; For I3 ; Prvar the excenters of the triangle ; Driver Code
code: function distance ( m , n , p , q ) { return Math . sqrt ( Math . pow ( n - m , 2 ) + Math . pow ( q - p , 2 ) * 1.0 ) ; } function Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) { var a = distance ( x2 , x3 , y2 , y3 ) ; var b = distance ( x3 , x1 , y3 , y1 ) ; var c = distance ( x1 , x2 , y1 , y2 ) ; var excenter = new Array ( 4 ) ; for ( var i = 0 ; i < 4 ; i ++ ) excenter [ i ] = new Array ( 2 ) ; excenter [ 1 ] [ 0 ] = ( - ( a * x1 ) + ( b * x2 ) + ( c * x3 ) ) / ( - a + b + c ) ; excenter [ 1 ] [ 1 ] = ( - ( a * y1 ) + ( b * y2 ) + ( c * y3 ) ) / ( - a + b + c ) ; excenter [ 2 ] [ 0 ] = ( ( a * x1 ) - ( b * x2 ) + ( c * x3 ) ) / ( a - b + c ) ; excenter [ 2 ] [ 1 ] = ( ( a * y1 ) - ( b * y2 ) + ( c * y3 ) ) / ( a - b + c ) ; excenter [ 3 ] [ 0 ] = ( ( a * x1 ) + ( b * x2 ) - ( c * x3 ) ) / ( a + b - c ) ; excenter [ 3 ] [ 1 ] = ( ( a * y1 ) + ( b * y2 ) - ( c * y3 ) ) / ( a + b - c ) ; for ( var i = 1 ; i <= 3 ; i ++ ) { document . write ( excenter [ i ] [ 0 ] + " " + excenter [ i ] [ 1 ] + " " ) ; } } var x1 , x2 , x3 , y1 , y2 , y3 ; x1 = 0 ; x2 = 3 ; x3 = 0 ; y1 = 0 ; y2 = 0 ; y3 = 4 ; Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) ;