在我的应用程序中,我想从北方计算特定位置的角度(给出纬度和经度)。有没有办法计算这个。实际上我已经找到了手机的方向,但我想获得位置的角度来自北方。这是我的代码。请提出任何相关的解决方案。谢谢
myAzimuth=Math.round(event.values[0]);
myPitch=Math.round(event.values[1]);
myRoll=Math.round(event.values[2]);
Toast.makeText(this, "Value"+myAzimuth, Toast.LENGTH_SHORT).show();
if(myAzimuth<22){
Toast.makeText(this, "North Direction", Toast.LENGTH_SHORT).show();
}
else if (myAzimuth >= 22 && myAzimuth < 67)
Toast.makeText(this, "North East", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 67 && myAzimuth < 112)
Toast.makeText(this, "East Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 112 && myAzimuth < 157)
Toast.makeText(this, "South east Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 157 && myAzimuth < 202)
Toast.makeText(this, "South Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 202 && myAzimuth < 247)
Toast.makeText(this, "South west Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 247 && myAzimuth < 292)
Toast.makeText(this, "west Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 292 && myAzimuth < 337)
Toast.makeText(this, "North west Direction", Toast.LENGTH_SHORT).show();
else if (myAzimuth >= 337)
Toast.makeText(this, "North Direction", Toast.LENGTH_SHORT).show();