I m having little trouble finding a relation between the movement at centre and edge of a circle, I
m为平移世界地图做准备,我的地图范围是180,89:-180,-89,我的地图通过添加变化平移(dx ,dY)到其范围而不是其中心。现在有一种情况出现了,我必须把地图移到一个特定的中心,计算经度的变化是非常简单和容易的,但是它引起了问题的变化。看起来地图中心的变化比地图Y边缘的变化更大,或者仅仅是如果我必须将地图中心从0long,0lat移动到73long,33lat,对于dX,我只得到73,但对于dY显然它看起来是33,但是如果我把33加到89的地图顶部,它会是122,这是不正确的,因为纬度在90到90之间。这似乎是一个二维平面上圆的投影,由于角度变化较小,中心向前后移动,并且中心变化更大,现在是否存在这两个因素之间的关系?我尝试将OriginY和destinationY之间的差异转换为弧度,然后添加到地图的顶部和底部,但它对我没有任何作用。请注意,地图是一个虚拟的画布上,其宽度从256开始,256 * 2^Z的增加,Z = 0是默认的,整个世界都在画布的那种程度可见如何找到地图中心和顶部/底部的纬度变化之间的关系
public void moveMapTo(double destinationLongitude,double destinationLattitude) // moves map to the new centre
{
double dXLong=destinationLongitude-centreLongitude; // centreLongitude and centreLattitude are centre of current map position
double atanhsinO = atanh(Math.sin(destinationLattitude * Math.PI/180.00));
double atanhsinD = atanh(Math.sin(centreLatitude * Math.PI/180.00));
double atanhCentre = (atanhsinD + atanhsinO)/2;
double latitudeSpan =destinationLattitude - centreLatitude;
double radianOfCentreLatitude = Math.atan(Math.sinh(atanhCentre));
double dXLat=latitudeSpan/Math.cos(radianOfCentreLatitude);
dXLat*=getLattitudeSpan()*(Math.PI/180); //<--- HERE IS THE PORBLEM
System.out.println("dxLong:"+dXLong+"_dxLat:"+dXLat);
//map left.right.top,bottom are current extents of map
mapLeft+=dXLong;
mapRight+=dXLong;
mapTop+=dXLat;
mapBottom+=dXLat;
}
private double getLattitudeSpan()
{
double latitudeSpan = mapTop - mapBottom;
latitudeSpan = latitudeSpan/Math.cos(radianOfCentreLatitude);
return Math.abs(latitudeSpan);
}
原帖发生了什么? – TheSteve0 2010-03-12 04:05:50