Point inside line and plane¶
Point vs line¶
To check if a point is on a line/segement.
1. PointInLine(P0,P,L)
It serves to check if P0 falls in the line (P,L).
P0 = np.array([0.5,0.5,0.5])
P = np.array([0,0,0])
L = np.array([1.1,1.1,1.1]) # slope
PointInLine(P0,P,L)
>>> True

2. PointInSegment(P0,P1,P2)
It serves to check if P0 falls in the segment (P1,P2).
P0 = np.array([0.5,0.5,0.5])
P1 = np.array([0,0,0])
P2 = np.array([0.4,0.4,0.4])
PointInLine(P0,P1,P2)
>>> False

Point vs plane¶
The point might be single or multiple.)
3. PointInPolygon(P0, polygon)
It serves to check if P0 falls in the polygon.
Point = np.array([0.5,0.5,0.5])
vertices = [(0,0,0),(1,0,0),(1,1,1),(0,1,1)]
polygon = np.array(vertices)
PointInPolygon(Point, polygon)
>>> True
4. PointsInPolygon2D(P0s, polygon)
It serves to check if multiple points P0s fall in the 2D polygon.
Points = np.array([(0,0),(0.5,0),(1,0),(1.5,0),(2,0)])
polygon = np.arraynp.array([(1,-1),(1,3),(2,1),(1.75,0)])
ret = PointsInPolygon2D(Points, polygon)
>>> array([False, False, True, True, False])
Points = np.array([[(0,0),(0.5,0)],[(1,0),(1.5,0)],[(2,0),(2.5,0]])
polygon = np.arraynp.array([(1,-1),(1,3),(2,1),(1.75,0)])
ret = PointsInPolygon2D(Points, polygon)
>>> array([[False, False], [True, True], [False,False]])

5. PointsInPolygon(P0s, polygon)
It serves to check if multiple points P0s fall in the 3D polygon.
Points = np.array([(0,0,0),(0.5,0,0),(1,0,0),(1.5,0,0),(2,0,0)])
polygon = np.arraynp.array([(1,-1,0),(1,3,0),(2,1,0),(1.75,0,0)])
ret = PointsInPolygon(Points, polygon)
>>> array([False, False, True, True, False])
6. Flow chart for their algorithm

