# comp.graphics.algorithms

## Subject: Re: common point of two planes

jindra wrote:
> thank you, but could you be more specific, i'm not trained in systems
> of equations and Gaussian elimination but I was thinking that it works
> only for square matrices, could you please tell me how to compose such
> matrix ???
> i know that two planes intersect at a line, i can compute directional
> vector of this line by taking cross-product of the normal vectors of
> the plane (which i think is fast from computational time point of
> view), but to fully specify the intersection line i need one point
> which lie on the intersection line and on both planes, so if there some
> fast way how to compute common point of two planes than the whole plane
> x plane intersection could be fast well
>
> jindra
>

Your problem is underconstrained. The two planes constrain only two
degrees of freedom (DOFs). By adding a third artificial DOF, you'll be
able to find a unique solution. Suppose dot(N1, X) = d1, dot(N2, X) = d2
are your plane equations and N3 = cross(N1, N2), the direction of the
line of intersection. You can take as added constraint dot(N3, X) = 0.
This constraint will give you the common point closest to the origin. So
you are basically solving the following linear system

[ N1^T ] X = [ d1 ]
[ N2^T ] [ d2 ]
[ N3^T ] [ 0 ]

where ^T denotes the transpose. (In a matrix, I regard all vectors as
columns. The normals here should be regarded as rows).

I guess Gaussian elimination is a bit of an overkill. I would go with
Cramer's rule which gives you the following solution:

Let Nx = (N1x, N2x, N3x), Ny = (N1y, N2y, N3y), Nz = (N1z, N2z, N3z),
and D = (d1, d2, 0) (These are all columns.)

Then, the system becomes

[Nx Ny Nz] X = D

For X = (x, y, z), we have the following solution

x = det[D N2 N3] / det[N1 N2 N3]
y = det[N1 D N3] / det[N1 N2 N3]
z = det[N1 N2 D] / det[N1 N2 N3]

Oh, and

det [ A B C ] = dot(A, cross(B, C))

So, there you have it. Yes, we needed to solve a system of linear
equations but in the end you only use dot and cross products.

One final remark: Since there is a zero in D, the determinant expression
can be further optimized. Just work out the determinants on a piece of
paper and remove some of the terms that are multiplied by zero.

Is this what you need?

Gino van den Bergen
www.dtecta.com