Line of intersection between two planes

后端 未结 6 1525
有刺的猬
有刺的猬 2020-12-01 07:12

How can I find the line of intersection between two planes?

I know the mathematics idea, and I did the cross product between the the planes normal vectors

b

6条回答
  •  清歌不尽
    2020-12-01 07:28

    The determinant-based approach is neat, but it's hard to follow why it works.

    Here's another way that's more intuitive.

    The idea is to first go from the origin to the closest point on the first plane (p1), and then from there go to the closest point on the line of intersection of the two planes. (Along a vector that I'm calling v below.)

    Given
    =====
     First plane: n1 • r = k1
    Second plane: n2 • r = k2
    
    Working
    =======
    dir = n1 × n2
    p1 = (k1 / (n1 • n1)) * n1
    v = n1 × dir
    pt = LineIntersectPlane(line = (p1, v), plane = (n2, k2))
    
    LineIntersectPlane
    ==================
    #We have n2 • (p1 + lambda * v) = k2
    lambda = (k2 - n2 • p1) / (n2 • v)
    Return p1 + lambda * v
    
    Output
    ======
    Line where two planes intersect: (pt, dir)
    

    This should give the same point as the determinant-based approach. There's almost certainly a link between the two. At least the denominator, n2 • v, is the same, if we apply the "scalar triple product" rule. So these methods are probably similar as far as condition numbers go.

    Don't forget to check for (almost) parallel planes. For example: if (dir • dir < 1e-8) should work well if unit normals are used.

提交回复
热议问题