我有java数学问题。我有以下表达:
double tripp = (timeNow-previousTime)/(seconds*Sys.getTimerResolution())*trip;
我试图计算我的立方体的旋转速度。这是我执行该功能的完整代码:
public float getTripLenghtToGo(int seconds, double trip) {
long timeNow = Sys.getTime();
System.out.println("RES: "+Sys.getTimerResolution());
double tripp = (timeNow-previousTime)/(seconds*Sys.getTimerResolution())*trip;
System.out.println("("+timeNow+"-"+previousTime+")/("+seconds+"*"+Sys.getTimerResolution()+")*"+trip+" = "+tripp);
if(tripp != 0){
previousTime = timeNow;
}
return (float)tripp;
}
我使用 OpenGL,所以它必须返回浮点数。它返回浮点数,但始终为零。