今天写程序要求两个平面的交线方程，叉乘一下两个normal就得到了直线的方向，但在求那个点的时候卡住了。自己写一个求点的程序，发现要check好多情况，程序好繁。实在忍受不了了，就google search一下居然有这么cool的求交线上任意点的方法，看来自己是在是太fool了。

### The intersection of two planes

Written by Paul Bourke

February 2000

The intersection of two planes (if they are not parallel) is a line.

Define the two planes with normals N as

**N _{1}** .

**p**= d

_{1}

**N _{2}** .

**p**= d

_{2}

The equation of the line can be written as

**p** = c_{1} **N _{1}** + c

_{2}

**N**+ u

_{2}**N***

_{1}**N**

_{2}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 c_{1} and c_{2}.

**N _{1}** .

**p**= d

_{1}= c

_{1}

**N**.

_{1}**N**+ c

_{1}_{2}

**N**.

_{1}**N**

_{2}**N _{2}** .

**p**= d

_{2}= c

_{1}

**N**.

_{1}**N**+ c

_{2}_{2}

**N**.

_{2}**N**

_{2}Solving for c_{1} and c_{2}

c_{1} = ( d_{1} **N _{2}** .

**N**– d

_{2}_{2}

**N**.

_{1}**N**) / determinant

_{2}c_{2} = ( d_{2} **N _{1}** .

**N**– d

_{1}_{1}

**N**.

_{1}**N**) / determinant

_{2}determinant = ( **N _{1}** .

**N**) (

_{1}**N**.

_{2}**N**) – (

_{2}**N**.

_{1}**N**)

_{2}^{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

**N _{1}** *

**N**= 0

_{2}
Feng更多的computational geometry在

http://local.wasp.uwa.edu.au/~pbourke/geometry/