From: Clive Tooth Subject: Re: Loxodromic midpoint Date: Wed, 06 Jan 1999 21:32:19 +0000 Newsgroups: sci.math Keywords: formulae for mercator projection Robert Hill wrote: > > k(Lon1-Lon0) = log((sec Lat1 + tan Lat1)/(sec Lat0 + tan Lat0)) > > > > So > > k = log((sec Lat1 + tan Lat1)/(sec Lat0 + tan Lat0))/(Lon1-Lon0) > > (3) > > Yes. > > > Integrating (2) from P0 to M gives: > > > > k(LonM-Lon0) = log((sec LatM + tan Lat1)/(sec LatM + tan Lat0)) > > Where do these expressions > > sec (one angle) + tan (a different angle) > > come from? I get > > k(LonM-Lon0) = log((sec LatM + tan LatM)/(sec Lat0 + tan Lat0)). > > However I haven't checked the ways you can transform this using (1), > so it may be equivalent to yours. Oh dear, oh dear! I am wrong and you are quite right. I cut'n'pasted an earlier equation and replaced the wrong bits of it with "M"s . > > giving > > > > LonM = Lon0+log((sec LatM + tan Lat1)/(sec LatM + tan Lat0))/k > > (4) > > > > Where LatM and LonM are already know from (1) and (3) above. > > I don't see why (4)'s right (see comment above). > > I'd like to get a symmetric expression for LonM. > To reduce the clutter, let's write f(x) = sec x + tan x. > (As far as I can see, we gain nothing from the fact that f(x) > can also be expressed as tan (pi/4 + x/2) or whatever it is.) > Then the equation of the curve is > > log(f(v)) = ku + const > > so g1 - g0 = k(Lon1 - Lon0) (5) > gM - g0 = k(LonM - Lon0) (6) > > where g0, g1, gM stand for log(f(Lat0)), log(f(Lat1)), log(f(LatM)). > > (5) is just a restatement of your (3). > Dividing (5) by (6) and rearranging, we get > > LonM = (gM(Lon1-Lon0) + g1 Lon0 - g0 Lon1)/ (g1-g0), > > or, expanding the g's and assuming monospace font, > > (Lon1-Lon0)log(f(LatM)) + Lon0 log(f(Lat1)) - Lon1 log(f(Lat0)) > LonM = ---------------------------------------------------------------. > log(f(Lat1)/f(Lat0)) > Agreed! A couple of asides... 1) There is, of course, a name for your "log(f(x))" = "log(sec(x)+tan(x))". It is the inverse Gudermannian function: gd^-1 (x). gd(x) being that lovely function 2 tan^-1 e^x - pi/2. 2) I was totally wrong in thinking I knew what Mercator's projection was! http://www.utexas.edu/depts/grg/ustudent/frontiers/fall95/meacham/meacham.html http://www.civil.buffalo.edu/cie/cie303/lect2.html I had assumed that it was the same as the equal-area cylindrical projection: http://www.ahand.unicamp.br/~furuti/ST/Cart/ProjCyl/projc.html but it isn't, and loxodromes are far from being straight lines in that projection. In fact, Mercator's projection does not seem to be a "geometrical projection" as such (if one attempts to imagine rays of light coming from some source, and shadows, etc). Suppose our aim is to define a projection in which loxodromes become straight lines. If x and y are the coordinates on the map, then, we must have k = dy/dx = sec v dv/du So, we could choose (as Mercator seems to have done)... x = const * integral du = const * u and y = const * integral sec v dv = const * gd^-1 (v) There are presumably uncountably many other projections where x is not linear in u... -- Clive Tooth http://www.pisquaredoversix.force9.co.uk/ End of document ============================================================================== From: Axel Harvey Subject: Re: Calculating lattitude Date: Thu, 15 Apr 1999 15:50:34 +0000 Newsgroups: sci.math On Thu, 15 Apr 1999, Joris Kroon wrote: > [ About Mercator maps.] ...What I > do is that I have a reference point somewhere on the map, say (0,0) with > latitude lat1 and longitude lon1. If my mouse is on the point (100,100) and > I want to calculate lat and lon I don't know what to do. Longitude is indeed > a linear function, so that is no problem. But latitude has to be calculated > using longitude somehow, I think. Longitude only comes into it as a scale-giving factor for your map-- *provided* it is a "straight-up" Mercator map where the lines of longitude and latitude are vertical and horizontal lines. If it is an oblique map, with curving lines, give another shout. (But it isn't, since you say the map is linear in longitude.) Maybe you can approach your problem from knowing how a Mercator map is constructed. At the equator, the length representing a longitude difference, say delta-L, is theoretically equal to the length representing a latitude difference, say delta-phi. To know how far from the equator to draw a a parallel of latitude phi, calculate in radians M = ( ln tan (Pi/4 + phi/2) )/phi and multiply the equatorial distance corresponding to the latitude by this factor (e.g., for 50 degrees North, multiply by M = 1.15815762... whatever distance your map has for a longitude difference of 50 degrees, and draw the parallel at the resulting distance from the equator). Presumably your mouse can figure backwards from this to find out where it is. The purpose of a Mercator map, by the way, is to make life easy for sailors: any straight line on the map is a constant course--if you follow it, your compass will always point in the same direction. For general geographic purposes there are many better projections. ============================================================================== From: horst.kraemer@snafu.de (Horst Kraemer) Subject: Re: Calculating lattitude Date: Thu, 15 Apr 1999 20:28:05 GMT Newsgroups: sci.math On Thu, 15 Apr 1999 14:36:28 +0200, "Joris Kroon" wrote: > I'm writing a program which displays a map. I would like to display the > coordinates of the position of the mouse on the map. The map is in Mercator > projection, so it is not so easy to do that. Longitude is no problem, > because it can be calculated directly from the mouse-coordinate. I've tried > to calculate lattitude in several different ways, but without success. > I have a reference point from which I calculate Longitude. If I do the same > with lattitude the deviation grows of course as I move further away from > that point. > Does anyone know how to solve this problem? Maybe you are not using correctly the formulas. Assuming a unit sphere the Mercator mapping function is ( L = Latitude, N = Northing on the map relative to the equator ) N = log tan (pi/4 + L/2) if you have a reference point (N0,L0) then N0 = log tan (pi/4 + L0/2) If the northing relative to the reference point DN = N-N0 is given through mouse coordinates you have to deduce L from DN: tan(pi/4 + L/2) DN = log ---------------- tan(pi/4 + L0/2) L = 2 * [ arctan (tan(pi/4 + L0/2) * exp(DN)) - pi/4 ] Regards Horst