PointInPolygon - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

ComputationalGeometry

 PointInPolygon
 determine if a point lies within the polygon formed by a list of points

 Calling Sequence PointInPolygon( P, Q )

Parameters

 P - a point in real 2-D space given as a list or rtable of coordinates Q - a list of points in real 2-D space

Description

 • This command returns a string describing the orientation of the point P relative to the polygon formed by the points Q. If P is inside the polygon then the command returns "inside". If P is outside then "outside" is returned. If P lies on the boundary of the polygon, then "boundary" is returned.

Examples

 > $\mathrm{with}\left(\mathrm{ComputationalGeometry}\right):$
 > $Q≔\left[\left[1.1180,0.36327\right],\left[0.,1.1756\right],\left[-1.1180,0.36327\right],\left[-0.69098,-0.95106\right],\left[0.69098,-0.95106\right]\right]$
 ${Q}{≔}\left[\left[{1.1180}{,}{0.36327}\right]{,}\left[{0.}{,}{1.1756}\right]{,}\left[{-1.1180}{,}{0.36327}\right]{,}\left[{-0.69098}{,}{-0.95106}\right]{,}\left[{0.69098}{,}{-0.95106}\right]\right]$ (1)
 > $a≔\left[0.,0.\right]:$$b≔\left[1.,1.\right]:$$c≔0.5{Q}_{1}+0.5{Q}_{2}:$
 > \mathrm{plots}:-\mathrm{display}\left(\mathrm{plottools}:-\mathrm{point}\left(\left[a,b,c\right],\mathrm{symbolsize}=20\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[{a}_{[]},"a"\right],\mathrm{align}=\left["above","left"\right]\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[{b}_{[]},"b"\right],\mathrm{align}=\left["above","left"\right]\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[{c}_{[]},"c"\right],\mathrm{align}=\left["below","left"\right]\right),\mathrm{plottools}:-\mathrm{polygon}\left(Q,\mathrm{style}=\mathrm{line}\right),\mathrm{axes}=\mathrm{box}\right)
 > $\mathrm{PointInPolygon}\left(a,Q\right)$
 ${"inside"}$ (2)
 > $\mathrm{PointInPolygon}\left(b,Q\right)$
 ${"outside"}$ (3)
 > $\mathrm{PointInPolygon}\left(c,Q\right)$
 ${"boundary"}$ (4)
 > $\mathrm{PointInPolygon}\left({Q}_{1},Q\right)$
 ${"boundary"}$ (5)
 > $\mathrm{PointInPolygon}\left(\mathrm{Array}\left(a\right),\mathrm{Array}\left(Q\right)\right)$
 ${"inside"}$ (6)
 > $\mathrm{PointInPolygon}\left(\mathrm{Array}\left(c\right),\mathrm{Array}\left(Q\right)\right)$
 ${"boundary"}$ (7)

Compatibility

 • The ComputationalGeometry[PointInPolygon] command was introduced in Maple 2020.
 • For more information on Maple 2020 changes, see Updates in Maple 2020.

 See Also