Equation of a straight line passing through a point and making a given angle with a given line | C ++ program for the above approach ; Function to find slope of given line ; Special case when slope of line is infinity or is perpendicular to x - axis ; Function to find equations of lines passing through the given point and making an angle with given line ; Store slope of given line ; Convert degrees to radians ; Special case when slope of given line is infinity : In this case slope of one line will be equal to alfa and the other line will be equal to ( 180 - alfa ) ; In this case slope of required lines can 't be  infinity ; g and f are the variables of required equations ; Print first line equation ; Print second line equation ; Special case when slope of required line becomes infinity ; General case ; g and f are the variables of required equations ; Print first line equation ; Print second line equation ; Driver Code ; Given Input ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; double line_slope ( double a , double b ) { if ( a != 0 ) return - b / a ; else return ( -2 ) ; } void line_equation ( double a , double b , double c , double x1 , double y1 , double alfa ) { double given_slope = line_slope ( a , b ) ; double x = alfa * 3.14159 / 180 ; if ( given_slope == -2 ) { double slope_1 = tan ( x ) ; double slope_2 = tan ( 3.14159 - x ) ; int g = x1 , f = x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 ) cout << " y ▁ = ▁ " << slope_1 << " x ▁ + " << g << endl ; if ( g <= 0 ) cout << " y ▁ = ▁ " << slope_1 << " x ▁ " << g << endl ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 ) { cout << " y ▁ = ▁ " << slope_2 << " x ▁ + " << f << endl ; } if ( f <= 0 ) cout << " y ▁ = ▁ " << slope_2 << " x ▁ " << f << endl ; return ; } if ( 1 - tan ( x ) * given_slope == 0 ) { cout << " x ▁ = ▁ " << x1 << endl ; } if ( 1 + tan ( x ) * given_slope == 0 ) { cout << " x ▁ = ▁ " << x1 << endl ; } double slope_1 = ( given_slope + tan ( x ) ) / ( 1 - tan ( x ) * given_slope ) ; double slope_2 = ( given_slope - tan ( x ) ) / ( 1 + tan ( x ) * given_slope ) ; int g = x1 , f = x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 && 1 - tan ( x ) * given_slope != 0 ) cout << " y ▁ = ▁ " << slope_1 << " x ▁ + " << g << endl ; if ( g <= 0 && 1 - tan ( x ) * given_slope != 0 ) cout << " y ▁ = ▁ " << slope_1 << " x ▁ " << g << endl ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 && 1 + tan ( x ) * given_slope != 0 ) { cout << " y ▁ = ▁ " << slope_2 << " x ▁ + " << f << endl ; } if ( f <= 0 && 1 + tan ( x ) * given_slope != 0 ) cout << " y ▁ = ▁ " << slope_2 << " x ▁ " << f << endl ; } int main ( ) { double a = 2 , b = 3 , c = -7 ; double x1 = 4 , y1 = 9 ; double alfa = 30 ; line_equation ( a , b , c , x1 , y1 , alfa ) ; return 0 ; } cout << fixed << setprecision ( 2 ) ;