【发布时间】:2014-10-18 19:07:24
【问题描述】:
我有来自 android 设备的 long 和 lat,但我的结果还不够好。我的意思是我的结果是整数:37.0 或 260.0 .. 我想要双数 37.001 - 37.999
我的代码:
// record the compass picture angle turned
private float currentDegree = 0f;
// device sensor manager
private SensorManager mSensorManager;
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
// get the angle around the z-axis rotated
float degree = Math.round(event.values[0]);
tvHeading.setText(Float.toString(degree));
// create a rotation animation (reverse turn degree degrees)
RotateAnimation ra = new RotateAnimation(
currentDegree,
-degree,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF,
0.5f);
// how long the animation will take place
ra.setDuration(210);
// set the animation after the end of the reservation status
ra.setFillAfter(true);
// Start the animation
currentDegree = -degree;
// updateWithNewLocation(l);
}
希望能提供帮助。谢谢。
问题已解决:需要这样定义度数:
float degree = event.values[0];
另一个问题是: 我的结果在 0.0 到 360.0 之间,我希望结果在 0.000 到 6400.999
之间问题也解决了: 使度数在 0 - 6400 之间:
double result =degree * 17.77777778;
degree = (float) result;
举个例子:3200 必须是 180 .. 180 * 17.77777778 正好是 3200。不管怎么说,还是要谢谢你。享受:)
【问题讨论】: