Created
October 19, 2022 14:54
-
-
Save guziy/78d806f1eec218e9009a0aa447359acb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FUNCTION inpoly_complex2(x,y,n,xx,yy) | |
!------------------------------------------------------------------------------- | |
! Determines if a point xx,yy is inside a complex polygon | |
! defined by x(n),y(n), | |
! ref : https://wrfranklin.org/Research/Short_Notes/pnpoly.html | |
! | |
!------------------------------------------------------------------------------- | |
implicit none | |
! arguments | |
integer n | |
real*8 x(n), y(n) , xx, yy | |
logical inpoly_complex2 | |
integer i, j | |
inpoly_complex2 = .false. | |
j = n | |
do i = 1, n | |
if ( ((y(i) > yy) /= (y(j) > yy)) .and. & | |
(xx < (x(j) - x(i)) * (yy - y(i)) / (y(j) - y(i)) + x(i)) ) then | |
inpoly_complex2 = .not. inpoly_complex2 | |
endif | |
j = i | |
enddo | |
END FUNCTION inpoly_complex2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment