How do I get three non-colinear points on a plane? - C++

后端 未结 3 1402
鱼传尺愫
鱼传尺愫 2020-12-30 16:41

I\'m trying to implement at line-plane intersection algorithm. According to Wikipedia I need three non-colinear points on the plane to do that.

I therefore tried imp

3条回答
  •  灰色年华
    2020-12-30 17:28

    One approach you may find easy to implement is to see where the plane intersects the coordinate axes. For the plane given by the equationaX + bY + cZ - d = 0 hold two variables at 0 and solve for the third. So the solutions would be (assuming a, b, c, and d are all non-zero):

    (d/a, 0, 0)
    (0, d/b, 0)
    (0, 0, d/c)
    

    You will need to consider the cases where one or more of the coefficients are 0 so you don't get a degenerate or colinear solutions. As an example if exactly one of the coefficients is 0 (say a=0) you instead use

    (1, d/b, 0)
    (0, d/b, 0)
    (0, 0, d/c)
    

    If exactly two of the coefficients are 0 (say a=0 and b=0) you can use:

    (1, 0, d/c)
    (0, 1, d/c)
    (0, 0, d/c)
    

    If d=0, the plane intersects the three axes at the origin, and so you can use:

    (1, 0, -a/c)
    (0, -c/b, 1)
    (-b/a, 1, 0)
    

    You will need to work out simular cases for d and exactly one other coefficient being 0, as well as d and two others being 0. There should be a total of 16 cases, but there are a few things that come to mind which should make that somewhat more manageable.

提交回复
热议问题