Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | xa | |||
real(kind=r64), | intent(in) | :: | ya | |||
real(kind=r64), | intent(in) | :: | xb | |||
real(kind=r64), | intent(in) | :: | yb | |||
real(kind=r64), | intent(in) | :: | xc | |||
real(kind=r64), | intent(in) | :: | yc |
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.
function angle_2dvector ( xa, ya, xb, yb, xc, yc ) result (angle)
! Function information:
! Author Linda Lawrie
! Date written October 2005
! Modified na
! Re-engineered na
! Purpose of this function:
! This function calculates the angle between two sides of a 2d polygon.
! It computes the interior angle in radians at vertex
! (XB,YB) of the chain formed by the directed edges from
! (XA,YA) to (XB,YB) to (XC,YC). The interior is to the
! left of the two directed edges.
! Methodology employed:
! <Description>
! References:
! Geometry Tools for Computer Graphics
! Use statements:
! na
Implicit none ! Enforce explicit typing of all variables in this routine
! Function argument definitions:
real(r64) , intent(in) :: xa ! vertex coordinate
real(r64) , intent(in) :: ya ! vertex coordinate
real(r64) , intent(in) :: xb ! vertex coordinate
real(r64) , intent(in) :: yb ! vertex coordinate
real(r64) , intent(in) :: xc ! vertex coordinate
real(r64) , intent(in) :: yc ! vertex coordinate
real(r64) angle ! the angle, between 0 and 2*PI.
! angle is set to PI/2 in the degenerate case.
! Function parameter definitions:
real(r64) , parameter :: epsilon=0.0000001d0
! Interface block specifications:
! na
! Derived type definitions:
! na
! Function local variable declarations:
real(r64) :: t
real(r64) :: x1
real(r64) :: x2
real(r64) :: y1
real(r64) :: y2
x1 = xa - xb
y1 = ya - yb
x2 = xc - xb
y2 = yc - yb
t = sqrt ( ( x1 * x1 + y1 * y1 ) * ( x2 * x2 + y2 * y2 ) )
if ( t == 0.0D+00 ) t = 1.0D+00
t = ( x1 * x2 + y1 * y2 ) / t
if ( (1.0D+00 - epsilon) < abs ( t ) ) then
t = sign ( 1.0D+00, t )
end if
angle = acos ( t )
if ( x2 * y1 - y2 * x1 < 0.0D+00 ) then
angle = 2.0D+00 * pi - angle
end if
return
end function angle_2dvector