Equation of a straight line with perpendicular distance D from origin and an angle A between the perpendicular from origin and x | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findLine ( int distance , float degree ) { float x = degree * 3.14159 / 180 ; if ( degree > 90 ) { cout << " Not ▁ Possible " ; return ; } float result_1 = sin ( x ) ; float result_2 = cos ( x ) ; cout << fixed << setprecision ( 2 ) << result_2 << " x ▁ + " << result_1 << " y ▁ = ▁ " << distance ; } int main ( ) { int D = 10 ; float A = 30 ; findLine ( D , A ) ; return 0 ; }