What algorithm is used in the PointInCurve component?

I’ve been “arguing” with one of them LLM “AI” chats about determining if point is inside a polygon.

First, IT considered my polygon as “degenerate” and said it’s impossible to determine if the point lies inside. Then after I asked it modified its suggested algorithm to be using convex hull, but fails when my point is out of the range of the polygon.

The poor thing is struggling.

Could anyone give me a hint what algorithm is used in grasshopper PointInCurve component?

Much obliged!

consider polygon with points:

{-22.421442091, 5.2017745651, 0}
{-22.421442091, -11.2406163016, 0}
{-9.86543452, -11.2406163016, 0}
{-9.86543452, -4.2451263692, 0}
{-4.8430314917, -4.2451263692, 0}
{-4.8430314917, 2.6307825387, 0}
{0.0597905122, 2.6307825387, 0}
{0.0597905122, 8.9087863242, 0}
{-17.5784105994, 8.9685768364, 0}

Hi @ivelin.peychev,

The bases for the GH component is Curve.Contains. I believe the implementation does some ray shooting.

– Dale

Yes, one of the suggestions was ray casting, but in case of one edges pointing inside the “if odd number of intersections → point inside” fails.

Thanks for the links I’ll look into that.