Calculate area and height of an isosceles triangle whose sides are radii of a circle | Function to convert given angle from degree to radian ; Function to calculate height and area of the triangle OAB ; Stores the angle OAB and OBA ; Stores the angle in radians ; Stores the height ; Print height of the triangle ; Stores the base of triangle OAB ; Stores the area of the triangle ; Print the area of triangle OAB ; Driver code
function Convert ( degree ) { var pi = 3.14159265359 ; return ( degree * ( pi / 180 ) ) ; } function areaAndHeightOfTraingle ( radius , a ) { if ( a >= 180 a == 0 ) { document . write ( " " ) ; return ; } var base_angle = ( 180 - a ) / 2 ; var radians = Convert ( base_angle ) ; var height = Math . sin ( radians ) * radius ; document . write ( " " + height + " " ) ; var Base = Math . cos ( radians ) * radius ; var area = Base * height ; document . write ( " " + area ) ; } var R = 5 , angle = 120 ; areaAndHeightOfTraingle ( R , angle ) ;