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
using System ; using System . Collections . Generic ; public class GFG { static double line_slope ( double a , double b ) { if ( a != 0 ) return - b / a ; else return ( - 2 ) ; } static 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 ; double slope_1 , slope_2 ; double g , f ; if ( given_slope == - 2 ) { slope_1 = Math . Tan ( x ) ; slope_2 = Math . Tan ( 3.14159 - x ) ; g = ( int ) x1 ; f = ( int ) x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . Round ( ( int ) g * 100.0 ) / 100.0 ) ) ; if ( g <= 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . Round ( ( int ) g * 100.0 ) / 100.0 ) ) ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 ) { Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . Round ( ( int ) f * 100.0 ) / 100.0 ) ) ; } if ( f <= 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . Round ( ( int ) g * 100.0 ) / 100.0 ) ) ; return ; } if ( 1 - Math . Tan ( x ) * given_slope == 0 ) { Console . WriteLine ( " x ▁ = ▁ " + ( Math . Round ( x1 * 100.0 ) / 100.0 ) ) ; } if ( 1 + Math . Tan ( x ) * given_slope == 0 ) { Console . WriteLine ( " x ▁ = ▁ " + ( Math . Round ( x1 * 100.0 ) / 100.0 ) ) ; } slope_1 = ( given_slope + Math . Tan ( x ) ) / ( 1 - Math . Tan ( x ) * given_slope ) ; slope_2 = ( given_slope - Math . Tan ( x ) ) / ( 1 + Math . Tan ( x ) * given_slope ) ; g = ( int ) x1 ; f = ( int ) x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 && 1 - Math . Tan ( x ) * given_slope != 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . Round ( ( int ) g * 100.0 ) / 100.0 ) ) ; if ( g <= 0 && 1 - Math . Tan ( x ) * given_slope != 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . Round ( ( int ) g * 100.0 ) / 100.0 ) ) ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 && 1 + Math . Tan ( x ) * given_slope != 0 ) { Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . Round ( ( int ) f * 100.0 ) / 100.0 ) ) ; } if ( f <= 0 && 1 + Math . Tan ( x ) * given_slope != 0 ) Console . WriteLine ( " y ▁ = ▁ " + ( Math . Round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . Round ( ( int ) f * 100.0 ) / 100.0 ) ) ; } public static void Main ( String [ ] args ) { double a = 2 , b = 3 , c = - 7 ; double x1 = 4 , y1 = 9 ; double alfa = 30 ; line_equation ( a , b , c , x1 , y1 , alfa ) ; } }