Find coordinates of the triangle given midpoint of each side | Return after solving the equations and finding the vertices coordinate . ; Finding sum of all three coordinate . ; Solving the equation . ; Finds vertices of a triangles from given middle vertices . ; Find X coordinates of vertices . ; Find Y coordinates of vertices . ; Output the solution . ; Driver code
function solve ( v ) { var res = [ ] ; var all3 = v [ 0 ] + v [ 1 ] + v [ 2 ] ; res . push ( all3 - v [ 1 ] * 2 ) ; res . push ( all3 - v [ 2 ] * 2 ) ; res . push ( all3 - v [ 0 ] * 2 ) ; return res ; } function findVertex ( xmid , ymid ) { var V1 = solve ( xmid ) ; var V2 = solve ( ymid ) ; for ( var i = 0 ; i < 3 ; i ++ ) { document . write ( V1 [ i ] + " " + V2 [ i ] + " " ) ; } } var xmid = [ 5 , 4 , 5 ] ; var ymid = [ 3 , 4 , 5 ] ; findVertex ( xmid , ymid ) ;