Equation of a straight line with perpendicular distance D from origin and an angle A between the perpendicular from origin and x | Function to find equation of a line whose distance from origin and angle made by the perpendicular from origin with x - axis is given ; Convert angle from degree to radian ; Handle the special case ; Calculate the sin and cos of angle ; Print the equation of the line ; Given Input ; Function Call
function findLine ( distance , degree ) { let x = degree * 3.14159 / 180 ; if ( degree > 90 ) { document . write ( " " ) ; return ; } let result_1 = Math . sin ( x ) ; let result_2 = Math . cos ( x ) ; document . write ( result_2 . toPrecision ( 2 ) + " " + result_1 . toPrecision ( 2 ) + " " + distance ) ; } let D = 10 ; let A = 30 ; findLine ( D , A ) ;