FE-Project
Loading...
Searching...
No Matches
Functions/Subroutines
scale_polygon Module Reference

module common / Polygon More...

Functions/Subroutines

logical function, public polygon_inpoly (pt_x, pt_y, num_node, v_x, v_y)
 Check whether the point is located inside a polyngon.
 

Detailed Description

module common / Polygon

Description
A module to provide utilities for polygon
Reference
Author
Yuta Kawai, Team SCALE

Function/Subroutine Documentation

◆ polygon_inpoly()

logical function, public scale_polygon::polygon_inpoly ( real(rp), intent(in) pt_x,
real(rp), intent(in) pt_y,
integer, intent(in) num_node,
real(rp), dimension(num_node), intent(in) v_x,
real(rp), dimension(num_node), intent(in) v_y )

Check whether the point is located inside a polyngon.

Definition at line 32 of file scale_polygon.F90.

33 implicit none
34 real(RP), intent(in) :: pt_x
35 real(RP), intent(in) :: pt_y
36 integer, intent(in) :: num_node
37 real(RP), intent(in) :: v_x(num_node)
38 real(RP), intent(in) :: v_y(num_node)
39 logical :: ret
40
41 integer :: wn
42 integer :: i, ii
43 !------------------------------------------
44
45 wn = 0
46 do i=1, num_node
47 ii = mod(i, num_node) + 1
48 if ( v_y(i) <= pt_y .and. pt_y < v_y(ii)) then
49 if( pt_x < v_x(i) + (pt_y - v_y(i)) * (v_x(ii) - v_x(i))/(v_y(ii) - v_y(i)) ) then
50 wn = wn + 1
51 end if
52 else if ( v_y(i) > pt_y .and. v_y(ii) <= pt_y ) then
53 if( pt_x < v_x(i) + (pt_y - v_y(i)) * (v_x(ii) - v_x(i))/(v_y(ii) - v_y(i)) ) then
54 wn = wn - 1
55 end if
56 end if
57 end do
58
59 if (wn == 0) then
60 ret = .false.
61 else
62 ret = .true.
63 end if
64
65 return