RE:Elemento incluido en un poligono
A hi va una función en basic de un tal G.Houck.No se si va a entrar aqui,tampoco se si funciona correctamente.' Hay que definir estas constantes
''Const OUTPOLY = 0% ' point is outside the polygon
' Const INPOLY = 1% ' point is inside the polygon
' Const ONPOLY = 2% ' point is on the polygon border or vertex
' Const C180 = -0.99999999999# ' approximation of cos(180)
' ------------------------------------------------------------------------
Function pointInPoly ( testPt as MBEPoint, polyPts() as MBEPoint, nPolyPts as long, epsilon as double ) as integer
dim i&, iec&, jj&, x_delta&, y_delta&
dim tsc#, tcc#, sc#, cc#, x1#, y1#, x2#, y2#
dim r1#, r2#, ct#, st#, vpl#
iec = 0
tsc = 0.0
sc = 0.0
tcc = 1.0
cc = 1.0
jj = nPolyPts
' calculate delta-x and delta-y
x_delta = polyPts(jj).x - testPt.x
y_delta = polyPts(jj).y - testPt.y
if abs(x_delta) <= epsilon then
if abs(y_delta) <= epsilon then
pointInPoly = ONPOLY
Exit Function
end if
end if
x1 = x_delta
y1 = y_delta
' calculate distance-squared to last point
r1 = (x1 * x1) + (y1 * y1)
' pt on top of vertex ?
if r1 <= epsilon then
pointInPoly = ONPOLY
Exit Function
end if
' cycle thru each boundary point, calculating
' distance to given pt for initial comparison
for i=1 to nPolyPts