Check if the given vectors are at equilibrium or not | Function to check the equilibrium of three vectors ; summing the x coordinates ; summing the y coordinates ; summing the z coordinates ; Checking the condition for equilibrium ; Driver code ; Checking for equilibrium
< ? php function checkEquilibrium ( $ x1 , $ y1 , $ z1 , $ x2 , $ y2 , $ z2 , $ x3 , $ y3 , $ z3 ) { $ resx = $ x1 + $ x2 + $ x3 ; $ resy = $ y1 + $ y2 + $ y3 ; $ resz = $ z1 + $ z2 + $ z3 ; if ( $ resx == 0 and $ resy == 0 and $ resz == 0 ) return true ; else return false ; } $ x1 = -2 ; $ y1 = -7 ; $ z1 = -9 ; $ x2 = 5 ; $ y2 = -14 ; $ z2 = 14 ; $ x3 = -3 ; $ y3 = 21 ; $ z3 = -5 ; if ( checkEquilibrium ( $ x1 , $ y1 , $ z1 , $ x2 , $ y2 , $ z2 , $ x3 , $ y3 , $ z3 ) ) echo " The ▁ vectors ▁ are ▁ at ▁ equilibrium . " ; else echo " The ▁ vectors ▁ are ▁ not ▁ at ▁ equilibrium . " ; ? >