Talk:Point-in-polygon

From aemwiki
Jump to: navigation, search

This algorithm seems to include both a "Ray to infinity" approach and a computation of winding (total net angle) around the point of interest. I do not understand why. The Ray to infinity seems far faster and more than accurate enough. --AEMPhil 08:41, 7 December 2007 (MST)


While it is faster (and therefore preferred away from the element) he ray-to-infinity approach is not consistent with the winding/AEM calculation, i.e., if the ray approach is used to calculate conductivity right along the boundary, we might be considered inside (to the right of a dipole/doublet jump) whereas the AEM solution might consider the same point to be on the left of the dipole/doublet jump. The calculation of head at this point will therefore be erroneous. By locally using the winding approach that is consistent with dipole/doublet jump calculations, we avoid this error. It's a trick I learned the hard way.

Notably, this algorithm can be considerably improved by storing the bounding box of each polygon. It is slowed, however, if the bounding box is recalculated on each call. --Analytophile 2:09, 7 December 2007


I understand your point. I would have made a different choice to handle this, but I realize this is purely subjective on my part. However, I did some testing and profiling because I was concerned about the efficiency: is seems that even when a point set is clearly outside of a polygon, the algorithm remains far slower than its ray casting counterpart. This is due to the time consumed in the calls to abs(z-zv[i]) which is rather inefficient (because of the square root involved I assume). I will attempt to improve that particular portion shortly. --AEMPhil 06:59, 12 December 2007 (MST)