Pergunta

I'm looking for an explanation on why there are 2 different mercator formulas discussed on these sites.

I understand this to be the correct mercator projection algorithm:

http://en.wikipedia.org/wiki/Mercator_projection

y = ln|sec(lat) + tan(lat)| 

However, this site refers to something completely different: http://wiki.openstreetmap.org/wiki/Mercator

#include <math.h>
double lat2y(double a) { return 180/M_PI * log(tan(M_PI/4+a*(M_PI/180)/2)); }

Any ideas?

Foi útil?

Solução

Both formulas are equal.

  • sec(x) + tan(x) = [ 1 + sin(x) ] / cos(x)

    sec(x) + tan(x) = [ 1 + sin(x) ] / cos(x)

  • tan(pi/4 + x/2) = sin(pi/4 + x/2) / cos(pi/4 + x/2) =

    = [cos(x/2) + sin(x/2)] / [cos(x/2) - sin(x/2)] =

    = [cos(x/2) + sin(x/2)]^2 / [cos(x/2) - sin(x/2)] / [cos(x/2) + sin(x/2)] =

    = [1 + 2*cos(x/2)*sin(x/2)] / [cos^2(x/2) - sin^2(x/2)] =

    = [1 + sin(x)] / cos(x)

    enter image description here

The latter formula is more convenient for numerical calculations, because it involves the computation of the trigonometric function only once.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top