4

I already have a formula that can calculate the distance between 2 geographic coordinates:

public function getGeoDistance(Coordinate $geoCoord1,Coordinate $geoCoord2){
    if(is_object($geoCoord1) && is_object($geoCoord2)){
        $aR = $geoCoord1->getLatitude()*(M_PI/180);
        $bR = $geoCoord2->getLatitude()*(M_PI/180);

        $latD = ($geoCoord2->getLatitude()-$geoCoord1->getLatitude())*(M_PI/180);
        $longD = ($geoCoord2->getLongitude()-$geoCoord1->getLongitude())*(M_PI/180);

        $a = pow(sin($latD/2), 2)+cos($aR)*cos($bR)*pow(sin($longD/2), 2);
        $c = 2*atan2(sqrt($a), sqrt(1-$a));

        return self::getWorldRadius()*$c;
    }

    return -1;
}

Now, i want to create another function that can calculate coordinates from another coordinate pair and distance value. The prototype is:

public function getGeoByGeoAndDistance(Coordinate $geoCoord1,int $distance):Coordinate

Does someone know the math beyond it?

P.S. the code is in PHP.

thanks.

Shlomi.

underdark
  • 84,148
  • 21
  • 231
  • 413
Shlomi
  • 267
  • 4
  • 6

1 Answers1

1

See this:

http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115

It's very well explained. You should not have problems to convert the code to php.

If I understand well what you want, you would use Problem 1B to find the azimuth and them the problem 1C to get your coordinate.

jeb
  • 1,668
  • 1
  • 14
  • 18