Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector) | :: | point | ||||
type(vector), | dimension(nsides) | :: | poly | |||
integer | :: | nsides |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Logical Function InPolygon(point, poly, nsides)
! this routine is not used in the current scheme
implicit none
!'Return TRUE if the point (xp,yp) lies inside the circumcircle
!'made up by points (x1,y1) (x2,y2) (x3,y3)
!'The circumcircle centre is returned in (xc,yc) and the radius r
!'NOTE: A point on the edge is inside the circumcircle
integer nsides
type(vector) :: point
type(vector), dimension(nsides) :: poly
real(r64), parameter :: epsilon=0.0000001d0
real(r64) :: anglesum
real(r64) :: costheta
integer :: vert
type(vector) :: p1
type(vector) :: p2
real(r64) :: m1
real(r64) :: m2
real(r64) :: acosval
InPolygon = .False.
anglesum=0.0d0
do vert=1,nsides-1
p1%x = poly(vert)%x - point%x
p1%y = poly(vert)%y - point%y
p1%z = poly(vert)%z - point%z
p2%x = poly(vert+1)%x - point%x
p2%y = poly(vert+1)%y - point%y
p2%z = poly(vert+1)%z - point%z
m1=modulus(p1)
m2=modulus(p2)
if (m1*m2 <= epsilon) then
InPolygon = .true.
exit
else
costheta = (p1%x*p2%x + p1%y*p2%y + p1%z*p2%z) / (m1*m2)
acosval=acos(costheta)
anglesum=anglesum+acosval
endif
enddo
if (abs(anglesum-twopi) <= epsilon) then
InPolygon=.true.
endif
return
End Function InPolygon