Check which side of a plane points are on

前端 未结 3 758
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 14:15

I\'m trying to take an array of 3D points and a plane and divide the points up into 2 arrays based on which side of the plane they are on. Before I get to heavily into debug

3条回答
  •  旧巷少年郎
    2020-12-05 14:46

    Following the 'put points into the plane's equation and check the sign' approach given previously. The equation can be easily obtained using SymPy. I used it to find location of points (saved as numpy arrays) in a list of points.

    from sympy import Point3D, Plane
    plane=Plane(Point3D(point1), Point3D(point2), Point3D(point3))
    for point in pointList:
            if plane.equation(x=point[0], y=point[1],z=point[2]) > 0:
                print "point is on side A"
            else:
                print "point is on side B"
    

    I haven't tested its speed compared to other methods mentioned above but is definitely the easiest method.

提交回复
热议问题