Mercator map projection logic conflict
Asked Answered
C

1

7

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?

Crankshaft answered 4/2, 2012 at 19:40 Comment(0)
L
7

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.

Likeminded answered 4/2, 2012 at 19:57 Comment(1)
+1 Thank you for the derivation - helped me a lot. In turn I've beautified your answer a bit. Hope you don't mind.Filip

© 2022 - 2024 — McMap. All rights reserved.