Code archives/Algorithms/InsidePoly

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

Download source code

InsidePoly by skidracer
(Posted 25 years ago)
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

Psilo
(Posted 21 years ago)
Thanks for that :)

Jim Brown
(Posted 18 years ago)
.

markcw
(Posted 18 years ago)
..

Plash
(Posted 18 years ago)
...!

Code Archives Forum