There’s a simpler explanation of the algorithm, without complex numbers. That value being computed is a signed angle of the curve, as viewed from the points on the plane.
When the point is inside the curve, that viewing angle is full circle = ±2·π radians. Doesn’t matter where you look, the line of sight will intersect the curve in even count of points. The sign depends on the winding order of the curve i.e. whether it winds clockwise or counter-clockwise.
Similarly, when the point is outside, that viewing angle is zero. Doesn’t matter where you look, the line of sight won’t intersect the curve, or it intersect the curve in even count of points, equal count in clockwise and counterclockwise directions.
BTW, the algorithm can be generalized to surfaces in 3D. The angle becomes a solid angle [1]. For points inside the surface that sum for the complete surface will be full sphere = ±4·π steradian, for points outside of the surface the sum will be zero. Particularly good for polygonal meshes, a single loop over faces of the mesh computes that signed solid angle.
3 comments
[ 3.4 ms ] story [ 27.0 ms ] threadWhen the point is inside the curve, that viewing angle is full circle = ±2·π radians. Doesn’t matter where you look, the line of sight will intersect the curve in even count of points. The sign depends on the winding order of the curve i.e. whether it winds clockwise or counter-clockwise.
Similarly, when the point is outside, that viewing angle is zero. Doesn’t matter where you look, the line of sight won’t intersect the curve, or it intersect the curve in even count of points, equal count in clockwise and counterclockwise directions.
BTW, the algorithm can be generalized to surfaces in 3D. The angle becomes a solid angle [1]. For points inside the surface that sum for the complete surface will be full sphere = ±4·π steradian, for points outside of the surface the sum will be zero. Particularly good for polygonal meshes, a single loop over faces of the mesh computes that signed solid angle.
[1] https://en.wikipedia.org/wiki/Solid_angle