Hi all, I don't want to sound stupid, but I am not a mathematical genius. What i do know that is it taking a projected point (on the screen in Spherical Mercartor) to find out the lat long,
public LatLon eastNorth2latlon(EastNorth p) { return new LatLon( Math.atan(Math.sinh(p.north()))*180/Math.PI, p.east()*180/Math.PI); } So the equivalent to this jsom code that I am porting is the open layers code. I think this might be correct, but I am not certain. They look different. http://trac.openlayers.org/browser/sandbox/crschmidt/google/lib/OpenLayers/Layer/GoogleMercator.js?rev=3791 inverseMercator: function(merc) { 221 222 var lon = (merc.lon / 20037508.34) * 180; 223 var lat = (merc.lat / 20037508.34) * 180; 224 225 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2); 226 227 return new OpenLayers.LonLat(lon, lat); 260 }, 261 But this projection transformation is common, and also done by the google maps api. I will have to look into this some more. thanks, mike On Jun 2, 4:37 pm, Eric <erjab...@gmail.com> wrote: > On Jun 2, 4:21 am, Brendan Kenny <bcke...@gmail.com> wrote: > > > 2) or, if it needs to remain in js-land, just expose a sinh() function > > for use just like the page at your first link suggests: (e^x - e^(- > > x)) / 2. Just be careful with your NaNs and Infs. > > Actually, be careful with small values of x too. > e^x = 1 + x +x^2/2 + x^3/6 +..., but > sinh x = x + x^3 / 6 + .... > > Using e^x directly for small values of x automatically loses > significant digits. > The mathematical definition of a special function is rarely the way > you want > to compute it. Look up computational procedures in AMS 55, or the > Numerical Recipes series. You might find yourself using continued > fractions, > or Pade approximants. You almost certainly want to use different > procedures > for different values of x. > > Given that you have expm1 available, try sinh x = e^(-x) (e^(2x) - 1) / > 2 if you > have nothing else available: Math.exp(-x) * Math.expm1(2.0*x) / 2.0. > Switch > to the standard method when |x| > 0.1. But in any case, use e^(-x) = > 1/e^x. > > Look up AMS 55 (Abromowitz and Stegun), the Numerical Recipes series > (Press, et al), > and Numerical Methods that (Usually) Work (Acton). > > Why is the original poster using hyperbolic functions anyway? > > Respectfully, > Eric Jablow -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.