Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a C implementation that I found, should be fairly straightforward to translate to PHP:</p> <pre><code>#define KmPerDegree 111.12000071117 #define DegreesPerKm (1.0/KmPerDegree) #define PI M_PI #define TwoPI (M_PI+M_PI) #define HalfPI M_PI_2 #define RadiansPerDegree (PI/180.0) #define DegreesPerRadian (180.0/PI) #define copysign(x,y) (((y)&lt;0.0)?-fabs(x):fabs(x)) #define NGT1(x) (fabs(x)&gt;1.0?copysign(1.0,x):(x)) #define ArcCos(x) (fabs(x)&gt;1?quiet_nan():acos(x)) #define hav(x) ((1.0-cos(x))*0.5) /* haversine */ #define ahav(x) (ArcCos(NGT1(1.0-((x)*2.0)))) /* arc haversine */ #define sec(x) (1.0/cos(x)) /* secant */ #define csc(x) (1.0/sin(x)) /* cosecant */ /* ** GreatCirclePos() -- ** ** Compute ending position from course and great-circle distance. ** ** Given a starting latitude (decimal), the initial great-circle ** course and a distance along the course track, compute the ending ** position (decimal latitude and longitude). ** This is the inverse function to GreatCircleDist). */ void GreatCirclePos(dist, course, slt, slg, xlt, xlg) double dist; /* -&gt; great-circle distance (km) */ double course; /* -&gt; initial great-circle course (degrees) */ double slt; /* -&gt; starting decimal latitude (-S) */ double slg; /* -&gt; starting decimal longitude(-W) */ double *xlt; /* &lt;- ending decimal latitude (-S) */ double *xlg; /* &lt;- ending decimal longitude(-W) */ { double c, d, dLo, L1, L2, coL1, coL2, l; if (dist &gt; KmPerDegree*180.0) { course -= 180.0; if (course &lt; 0.0) course += 360.0; dist = KmPerDegree*360.0-dist; } if (course &gt; 180.0) course -= 360.0; c = course*RadiansPerDegree; d = dist*DegreesPerKm*RadiansPerDegree; L1 = slt*RadiansPerDegree; slg *= RadiansPerDegree; coL1 = (90.0-slt)*RadiansPerDegree; coL2 = ahav(hav(c)/(sec(L1)*csc(d))+hav(d-coL1)); L2 = HalfPI-coL2; l = L2-L1; if ((dLo=(cos(L1)*cos(L2))) != 0.0) dLo = ahav((hav(d)-hav(l))/dLo); if (c &lt; 0.0) dLo = -dLo; slg += dLo; if (slg &lt; -PI) slg += TwoPI; else if (slg &gt; PI) slg -= TwoPI; *xlt = L2*DegreesPerRadian; *xlg = slg*DegreesPerRadian; } /* GreatCirclePos() */ </code></pre> <blockquote> <h3>Source: <a href="http://sam.ucsd.edu/sio210/propseawater/ppsw_c/gcdist.c" rel="noreferrer">http://sam.ucsd.edu/sio210/propseawater/ppsw_c/gcdist.c</a></h3> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload