开发者

math experts - express log/ln function in JavaScript

I would like to find log/ln equation and express in javascript to graph google maps zoom aga开发者_Go百科inst km distance. Unfortunately my javascript skills are better than my math skills.

Values are approximate.

km  zoom    
5   13  
10  11  
20  10  
40  9   
80  8   
160 7   
180 6   

something like:

zoom = Math.round((13/Math.log(km)));


I'd use the equation

zoom = 11 - log(km/10)/log(2),

which matches the zoom for your km values between 10 and 160.


This is probably closer to what you want:

zoom = Math.round((18/Math.log(km))+2);


It's hard to tell from the approximate values, but it ought to be in terms of logarithms, as you guessed.

You could try curve fitting, since the approximate values don't seem to match a consistent log base (they're near log base 2 at the bottom, base sqrt(2) at the top).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜