-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangles.chpl
More file actions
29 lines (28 loc) · 936 Bytes
/
angles.chpl
File metadata and controls
29 lines (28 loc) · 936 Bytes
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
// -----------------------------------------------------------------------------
// --> todec: converts degrees, minutes and seconds to decimals
//
//
// input: ggg.mmss ( degrees (gg), minutes (mm) and seconds (ss) )
// output: ggg.xxxx ( decimal degrees )
// -----------------------------------------------------------------------------
proc todec(
in xmsc: real
): real {
var xint = trunc(xmsc);
var xdec = xint;
xmsc = (xmsc - xint)*100.0;
xint = nearbyint(xmsc);
xdec += xint/60.0;
xmsc = (xmsc - xint)*100;
xdec += xmsc/3600.0;
return(xdec) ;
}
// -----------------------------------------------------------------------------
// rad2dec: convert from radians to decimal degrees
// -----------------------------------------------------------------------------
inline proc rad2dec(const in r: real): real {
return r*180.0/pi;
}
inline proc dec2rad(const in r: real): real {
return r*pi/180.0;
}