Check which side of a plane points are on

前端 未结 3 756
佛祖请我去吃肉
佛祖请我去吃肉 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.

    0 讨论(0)
  • 2020-12-05 14:48

    Let a*x+b*y+c*z+d=0 be the equation determining your plane.

    Substitute the [x,y,z] coordinates of a point into the left hand side of the equation (I mean the a*x+b*y+c*z+d) and look at the sign of the result.

    The points having the same sign are on the same side of the plane.

    Honestly, I did not examine the details of what you wrote. I guess you agree that what I propose is simpler.

    0 讨论(0)
  • 2020-12-05 15:11

    Your approach sounds good. However, when you say "and turn them into vectors", it might not be good (depending on the meaning of your sentence).

    You should "turn your points into vector" by computing the difference in terms of coordinates between the current point and one of the points in the plane (for example, one of the 3 points defining the plane). As you wrote it, it sounds like you might have misunderstood that ; but apart from that, it's ok!

    0 讨论(0)
提交回复
热议问题