I have a Winkel Tripel map that I need to place markers over. Im given the position of the markers in Latitude/ Longitude. So I need a way to convert it to X,Y.
I found some code (below), but when I tried it out, the plot of a 45ยบ diagonal line has a moderate s-curve to it. So it's obviously not correct.
Any help would be great. Im doing this in PHP, but I should be able to convert any language.
private function sinc($x){
if($x == 0) return 1;
return sin($x) / $x;
}
private function winkelTripelToCartesian($lat, $lng){
$lat = deg2rad($lat);
$lng = deg2rad($lng);
$alpha = acos(cos($lat) * cos($lng / 2));
$x = ($lng * M_2_PI + (2 * cos($lat) * sin($lng / 2)) / $this->sinc($alpha)) / 2;
$y = ($lat + (sin($lat) / $this->sinc($alpha))) / 2;
return array('x'=> strval($x), 'y' => strval($y));
}