I've been wondering for a long time and I can't find, where is my fault.
I write simple program to compute line of two planes intersection.
function getIntersectOf2Planes ( $P1 , $P2 )
{
/* Line equation in parametric form:
x = x0 + t*a
y = y0 + t*b
z = z0 + t*c
*/
$x0 = ( $P1->B * $P2->D - $P2->B * $P1->D ) / ( $P1->A * $P2->B - $P2->A * $P1->B ) ;
$a = ( $P1->B * $P2->C - $P2->B * $P1->C );
$y0 = ( $P2->A * $P1->D - $P1->A * $P2->D ) / ( $P1->A * $P2->B - $P2->A * $P1->B ) ;
$b = ( $P2->A * $P1->C - $P1->A * $P2->C );
$z0 = 0;
$c = 1;
}
I found this formula on site: http://www.ambrsoft.com/TrigoCalc/Plan3D/Plane3D_.htm
But when i run my program for planes: Plane1: -25x -10y +4z +125 = 0 Plane2: 2x +21y -8z -12 =0
I have a result:
x0 = 4.960396039604
y0 = 0.099009900990099
z0 = 0
a = -4
b = -192
c = 1
What means:
x = 4.96 -4t (rounded)
y = 0.1 -192t
z = t
But the online calculators, give me:
x = 4.96 − 4t
y = 0.1 − 192t
z = − 505t
As you can see, the 'c' parametr is a problem.
How to fix it?
//EDIT: Looking on:
$a = ( $P1->B * $P2->C - $P2->B * $P1->C );
$b = ( $P2->A * $P1->C - $P1->A * $P2->C );
I tried:
$c = ( $P1->A * $P2->B - $P2->A * $P1->B );
and it's working. But why? Why on this site above is:
z = t