Coplanarity of Two Lines in 3D Geometry | Java program implement the above approach ; Function to generate determinant ; Return the sum ; Driver Code ; Position vector of first line ; Direction ratios of line to which first line is parallel ; Position vectors of second line ; Direction ratios of line to which second line is parallel ; Determinant to check coplanarity ; If determinant is zero ; Otherwise
import java . io . * ; class GFG { static int det ( int [ ] [ ] d ) { int Sum = d [ 0 ] [ 0 ] * ( ( d [ 1 ] [ 1 ] * d [ 2 ] [ 2 ] ) - ( d [ 2 ] [ 1 ] * d [ 1 ] [ 2 ] ) ) ; Sum -= d [ 0 ] [ 1 ] * ( ( d [ 1 ] [ 0 ] * d [ 2 ] [ 2 ] ) - ( d [ 1 ] [ 2 ] * d [ 2 ] [ 0 ] ) ) ; Sum += d [ 0 ] [ 2 ] * ( ( d [ 0 ] [ 1 ] * d [ 1 ] [ 2 ] ) - ( d [ 0 ] [ 2 ] * d [ 1 ] [ 1 ] ) ) ; return Sum ; } public static void main ( String [ ] args ) { int x1 = - 3 , y1 = 1 , z1 = 5 ; int a1 = - 3 , b1 = 1 , c1 = 5 ; int x2 = - 1 , y2 = 2 , z2 = 5 ; int a2 = - 1 , b2 = 2 , c2 = 5 ; int [ ] [ ] det_list = { { x2 - x1 , y2 - y1 , z2 - z1 } , { a1 , b1 , c1 } , { a2 , b2 , c2 } } ; if ( det ( det_list ) == 0 ) System . out . print ( " Lines ▁ are ▁ coplanar " ) ; else System . out . print ( " Lines ▁ are ▁ non ▁ coplanar " ) ; } }