Equation of a straight line passing through a point and making a given angle with a given line | Python3 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
import math NEW_LINE def line_slope ( a , b ) : NEW_LINE INDENT if ( a != 0 ) : NEW_LINE INDENT return - b / a NEW_LINE DEDENT else : NEW_LINE INDENT return ( - 2 ) NEW_LINE DEDENT DEDENT def line_equation ( a , b , c , x1 , y1 , alfa ) : NEW_LINE INDENT given_slope = line_slope ( a , b ) NEW_LINE x = alfa * 3.14159 / 180 NEW_LINE if ( given_slope == - 2 ) : NEW_LINE INDENT slope_1 = math . tan ( x ) NEW_LINE slope_2 = math . tan ( 3.14159 - x ) NEW_LINE g = x1 , f = x1 NEW_LINE g *= ( - slope_1 ) NEW_LINE g += y1 NEW_LINE if ( g > 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_1 , 2 ) , " x ▁ + " , round ( g ) ) ; NEW_LINE DEDENT if ( g <= 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_1 , 2 ) , " x ▁ " , round ( g ) ) NEW_LINE DEDENT f *= ( - slope_2 ) NEW_LINE f += y1 NEW_LINE if ( f > 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_2 , 2 ) , " x ▁ + " , round ( f ) ) NEW_LINE DEDENT if ( f <= 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_2 , 2 ) , " x ▁ " , round ( f ) ) NEW_LINE DEDENT return NEW_LINE DEDENT if ( 1 - math . tan ( x ) * given_slope == 0 ) : NEW_LINE INDENT print ( " x ▁ = " , x1 ) NEW_LINE DEDENT if ( 1 + math . tan ( x ) * given_slope == 0 ) : NEW_LINE INDENT print ( " x ▁ = " , x1 ) NEW_LINE DEDENT slope_1 = ( ( given_slope + math . tan ( x ) ) / ( 1 - math . tan ( x ) * given_slope ) ) NEW_LINE slope_2 = ( ( given_slope - math . tan ( x ) ) / ( 1 + math . tan ( x ) * given_slope ) ) NEW_LINE g = x1 NEW_LINE f = x1 NEW_LINE g *= ( - slope_1 ) NEW_LINE g += y1 NEW_LINE if ( g > 0 and 1 - math . tan ( x ) * given_slope != 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_1 , 2 ) , " x ▁ + " , round ( g ) ) NEW_LINE DEDENT if ( g <= 0 and 1 - math . tan ( x ) * given_slope != 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_1 , 2 ) , " x ▁ " , round ( g ) ) NEW_LINE DEDENT f *= ( - slope_2 ) NEW_LINE f += y1 NEW_LINE if ( f > 0 and 1 + math . tan ( x ) * given_slope != 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_2 , 2 ) , " x ▁ + " , round ( f ) ) NEW_LINE DEDENT if ( f <= 0 and 1 + math . tan ( x ) * given_slope != 0 ) : NEW_LINE INDENT print ( " y ▁ = ▁ " , round ( slope_2 , 2 ) , " x ▁ " , round ( f ) ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = 2 NEW_LINE b = 3 NEW_LINE c = - 7 NEW_LINE x1 = 4 NEW_LINE y1 = 9 NEW_LINE alfa = 30 NEW_LINE line_equation ( a , b , c , x1 , y1 , alfa ) NEW_LINE DEDENT