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.

1

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.