blob: 6ef94c84f3a07e26d368513eeff767d2c600ceb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*@@
@file phif.F
@date October 1998
@author Miguel Alcubierre
@desc
Function to find angle phi from coordinates {x,y}.
@enddesc
@version $Header$
@@*/
#include "cctk.h"
CCTK_REAL function phif(x,y)
implicit none
CCTK_REAL x,y
CCTK_REAL zero,half,one,two,pi
c Numbers.
zero = 0.0D0
half = 0.5D0
one = 1.0D0
two = 2.0D0
pi = acos(-one)
c Find angle between 0 and pi/2 such that tan(phi) = |y/x|.
if (dabs(x).gt.dabs(y)) then
phif = atan(dabs(y/x))
else if (dabs(x).lt.dabs(y)) then
phif = half*pi - atan(dabs(x/y))
else
phif = 0.25D0*pi
end if
c Use signs of {x,y} to move to correct quadrant.
if ((x.eq.zero).and.(y.eq.zero)) then
phif = zero
else if ((x.le.zero).and.(y.ge.zero)) then
phif = pi - phif
else if ((x.le.zero).and.(y.le.zero)) then
phif = pi + phif
else if ((x.ge.zero).and.(y.le.zero)) then
phif = two*pi - phif
end if
return
end
|