Length of Diagonal of a n | Function to find the diagonal of a regular polygon ; Side and side length cannot be negative ; diagonal degree converted to radians ; Driver code
< ? php function polydiagonal ( $ n , $ a ) { if ( $ a < 0 && $ n < 0 ) return -1 ; return 2 * $ a * sin ( ( ( ( $ n - 2 ) * 180 ) / ( 2 * $ n ) ) * 3.14159 / 180 ) ; } $ a = 9 ; $ n = 10 ; echo polydiagonal ( $ n , $ a ) ; ? >