2017-02-14 32 views
-1

從這段代碼我有幾個問題與sqrt,sin & COS不能解決方法和EPSILON無法解析符號。我是否需要在數學庫中添加sin cos & sqrt?如果是,你可以給我鏈接下載jar嗎?問題與不能解決方法和符號

float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ); 

     // Normalize the rotation vector if it's big enough to get the axis 
     // (that is, EPSILON should represent your maximum allowable margin of error) 
     if (omegaMagnitude > EPSILON) { 
      axisX /= omegaMagnitude; 
      axisY /= omegaMagnitude; 
      axisZ /= omegaMagnitude; 
     } 

     // Integrate around this axis with the angular speed by the timestep 
     // in order to get a delta rotation from this sample over the timestep 
     // We will convert this axis-angle representation of the delta rotation 
     // into a quaternion before turning it into the rotation matrix. 
     float thetaOverTwo = omegaMagnitude * dT/2.0f; 
     float sinThetaOverTwo = sin(thetaOverTwo); 
     float cosThetaOverTwo = cos(thetaOverTwo); 
+1

JAR?這是Java?這些應該是Math.sqrt,Math.sin和Math.cos。 EPSILON應該被定義爲你的雙倍。沒有圖書館需要。 – duffymo

+0

我懷疑你複製和粘貼的代碼有'import static java.lang.Math.sqrt;'(對於其他函數以及EPSILON常量類似)。 –

+0

我已經嘗試使用導入靜態java.lang.Math.sqrt;但float omegaMagnitude = sqrt(axisX * axisX + axisY * axisY + axisZ * axisZ);以紅色加下劃線。對於EPSILON im不知道如何將其定義爲double。 – MdZain

回答

0

您不必下載任何其他庫。 使用Math.sin(x), Math.cos(x) and Math.sqrt(x)sin(x), cos(x) and sqrt(x)和下面的代碼放置在你的文件的頂部(而行package [...],如果存在如下):

// For Math.xxx() 
import java.lang.Math; 

// For xxx() 
import static java.lang.Math.sin; 
import static java.lang.Math.cos; 
import static java.lang.Math.sqrt; 

如果你使用的是Eclipse只需按Ctrl + Shift + O自動組織進口(其他IDE應該有類似的快捷鍵)。