c = 2 * arcsin(min(1,sqrt(a))) ]]>

copy the sin prototype and change “sin” to “asin” both times,

d asin pr 8f extproc('asin') d parm1 8f const

then

if a < 1; c = 2 * asin(sqrt(a)); else; c = 2 * asin(1); endif;]]>

should have been min(1,sqrt(a)) ??

heres a site discussing it

http://www.cs.nyu.edu/visual/home/proj/tiger/gisfaq.html

but the original source seems to be gone.

dlon = lon2 – lon1

dlat = lat2 – lat1

a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2

**c = 2 * arcsin(min(1,sqrt(a)))**

d = R * c

where R is the radius of the Earth.

]]>C+ set :c = 2 * atan2(sqrt(:a), sqrt(1 – :a))

C+ set :c = 2 * asin(min(sqrt(:a)))

It doesn’t seem to calc correctly with stmt one. another version i’ve seen out there is stmt 2. but RPG doesn’t like the min part. any ideas on that?

]]>Computations are in km, you probably want them in miles ]]>

use 3956 for miles ]]>

degrees * pi/180 = radians

where pi = 3.1415926 (approx.) since I wasn’t sure if there was a c function that did the conversion.

]]>http://www.rpgiv.com/rpgnews/Feb99a/highmath.html

C library

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c4156070.pdf

Anyone got a sample RPGLE -C math

need to radians, sin, cos, atan, sqrt