Equation of a straight line passing through a point and making a given angle with a given line | Java 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 java . io . * ; 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 ; if ( given_slope == - 2 ) { double slope_1 = Math . tan ( x ) ; double slope_2 = Math . tan ( 3.14159 - x ) ; int g = ( int ) x1 , f = ( int ) x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . round ( g * 100.0 ) / 100.0 ) ) ; if ( g <= 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . round ( g * 100.0 ) / 100.0 ) ) ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 ) { System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . round ( f * 100.0 ) / 100.0 ) ) ; } if ( f <= 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . round ( g * 100.0 ) / 100.0 ) ) ; return ; } if ( 1 - Math . tan ( x ) * given_slope == 0 ) { System . out . println ( " x ▁ = ▁ " + ( Math . round ( x1 * 100.0 ) / 100.0 ) ) ; } if ( 1 + Math . tan ( x ) * given_slope == 0 ) { System . out . println ( " x ▁ = ▁ " + ( Math . round ( x1 * 100.0 ) / 100.0 ) ) ; } double slope_1 = ( given_slope + Math . tan ( x ) ) / ( 1 - Math . tan ( x ) * given_slope ) ; double slope_2 = ( given_slope - Math . tan ( x ) ) / ( 1 + Math . tan ( x ) * given_slope ) ; int g = ( int ) x1 , f = ( int ) x1 ; g *= ( - slope_1 ) ; g += y1 ; if ( g > 0 && 1 - Math . tan ( x ) * given_slope != 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . round ( g * 100.0 ) / 100.0 ) ) ; if ( g <= 0 && 1 - Math . tan ( x ) * given_slope != 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_1 * 100.0 ) / 100.0 ) + " x ▁ " + ( Math . round ( g * 100.0 ) / 100.0 ) ) ; f *= ( - slope_2 ) ; f += y1 ; if ( f > 0 && 1 + Math . tan ( x ) * given_slope != 0 ) { System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . round ( f * 100.0 ) / 100.0 ) ) ; } if ( f <= 0 && 1 + Math . tan ( x ) * given_slope != 0 ) System . out . println ( " y ▁ = ▁ " + ( Math . round ( slope_2 * 100.0 ) / 100.0 ) + " x ▁ + " + ( Math . round ( 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 ) ; } }