Code archives/Algorithms/InsidePoly

This code has been declared by its author to be Public Domain code.

Download source code

InsidePoly by skidracer2001
check if a point is inside a polygon
Function dot(x0,y0,x1,y1,x2,y2)
	Return (x1-x0)*(y2-y1)-(x2-x1)*(y1-y0)
End Function

Function InsideQuad(px,py,x0,y0,x1,y1,x2,y2,x3,y3)
	If dot(x0,y0,x1,y1,px,py)>0
		If dot(x1,y1,x2,y2,px,py)>0
			If dot(x2,y2,x3,y3,px,py)>0
				If dot(x3,y3,x0,y0,px,py)>0
					Return True
				EndIf
			EndIf
		EndIf
	EndIf
End Function

Comments

Psilo2006
Thanks for that :)


Code Archives Forum