Find coordinates of the triangle given midpoint of each side | Java program to find coordinate 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
import java . util . Vector ; class GFG { static final int N = 3 ; static Vector < Integer > solve ( int v [ ] ) { Vector < Integer > res = new Vector < Integer > ( ) ; int all3 = v [ 0 ] + v [ 1 ] + v [ 2 ] ; res . add ( all3 - v [ 1 ] * 2 ) ; res . add ( all3 - v [ 2 ] * 2 ) ; res . add ( all3 - v [ 0 ] * 2 ) ; return res ; } static void findVertex ( int xmid [ ] , int ymid [ ] ) { Vector < Integer > V1 = solve ( xmid ) ; Vector < Integer > V2 = solve ( ymid ) ; for ( int i = 0 ; i < 3 ; i ++ ) { System . out . println ( V1 . get ( i ) + " ▁ " + V2 . get ( i ) ) ; } } public static void main ( String [ ] args ) { int xmid [ ] = { 5 , 4 , 5 } ; int ymid [ ] = { 3 , 4 , 5 } ; findVertex ( xmid , ymid ) ; } }