The intersection of two planes (if they are not parallel) is a line.
Define the two planes with normals N as
N2 . p = d2
The equation of the line can be written as
Where "*" is the cross product, "." is the dot product, and u is the parameter of the line.
Taking the dot product of the above with each normal gives two equations with unknowns c1 and c2.
N2 . p = d2 = c1 N1 . N2 + c2 N2 . N2
Solving for c1 and c2
c2 = ( d2 N1 . N1 - d1 N1 . N2) / determinant
determinant = ( N1 . N1 ) ( N2 . N2 ) - ( N1 . N2 )2
Note that a test should first be performed to check that the planes aren't parallel or coincident (also parallel), this is most easily achieved by checking that the cross product of the two normals isn't zero. The planes are parallel if