Raycast shows an implementation of the ray casting point-in-polygon (PNPoly) algorithm for testing if a point is inside a closed polygon. Also known as the crossing number or the even-odd rule algorithm.
The implementation follows https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html