Find all angles of a triangle in 3D | function for finding the angle ; Driver code
function angle_triangle ( x1 , x2 , x3 , y1 , y2 , y3 , z1 , z2 , z3 ) { let num = ( x2 - x1 ) * ( x3 - x1 ) + ( y2 - y1 ) * ( y3 - y1 ) + ( z2 - z1 ) * ( z3 - z1 ) ; let den = Math . sqrt ( Math . pow ( ( x2 - x1 ) , 2 ) + Math . pow ( ( y2 - y1 ) , 2 ) + Math . pow ( ( z2 - z1 ) , 2 ) ) * Math . sqrt ( Math . pow ( ( x3 - x1 ) , 2 ) + Math . pow ( ( y3 - y1 ) , 2 ) + Math . pow ( ( z3 - z1 ) , 2 ) ) ; let angle = Math . acos ( num / den ) * ( 180.0 / 3.141592653589793238463 ) ; return angle ; } let x1 = - 1 ; let y1 = 3 ; let z1 = 2 ; let x2 = 2 ; let y2 = 3 ; let z2 = 5 ; let x3 = 3 ; let y3 = 5 ; let z3 = - 2 ; let angle_A = angle_triangle ( x1 , x2 , x3 , y1 , y2 , y3 , z1 , z2 , z3 ) ; let angle_B = angle_triangle ( x2 , x3 , x1 , y2 , y3 , y1 , z2 , z3 , z1 ) ; let angle_C = angle_triangle ( x3 , x2 , x1 , y3 , y2 , y1 , z3 , z2 , z1 ) ; document . write ( " " ) ; document . write ( " " + angle_A + " " ) ; document . write ( " " + angle_B . toFixed ( 3 ) + " " ) ; document . write ( " " + angle_C . toFixed ( 3 ) + " " ) ;