Вот есть хорошие примеры.
http://paulbourke.net/geometry/insidepoly/