Equation of a straight line with perpendicular distance D from origin and an angle A between the perpendicular from origin and x | Java program for the approach ; 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 ; Driver Code ; Given Input ; Function Call
class GFG { static void findLine ( int distance , float degree ) { float x = ( float ) ( degree * 3.14159 / 180 ) ; if ( degree > 90 ) { System . out . print ( " Not ▁ Possible " ) ; return ; } float result_1 = ( float ) Math . sin ( x ) ; float result_2 = ( float ) Math . cos ( x ) ; System . out . print ( String . format ( " % .2f " , result_2 ) + " x ▁ + " + String . format ( " % .2f " , result_1 ) + " y ▁ = ▁ " + distance ) ; } public static void main ( String [ ] args ) { int D = 10 ; float A = 30 ; findLine ( D , A ) ; } }