Type ePoint(X As Double, Y As Double)
Public Sub IsPointInPolygon(polygon() As ePoint, X As Double, Y As Double) As Boolean
Dim result As Boolean = False
Dim j As Int = polygon.length - 1
For i = 0 To polygon.length - 1
If polygon(i).Y < Y And polygon(j).Y >= Y Or polygon(j).Y < Y And polygon(i).Y >= Y Then
If polygon(i).X + (Y - polygon(i).Y) / (polygon(j).Y - polygon(i).Y) * (polygon(j).X - polygon(i).X) < X Then
result = Not(result)
End If
End If
j = i
Next
Return result
End Sub