简体   繁体   English

无法解决方法和符号的问题

[英]Issue with cannot resolve method & symbol

From this code I have a few issue with the sqrt, sin & cos cannot resolve method and the EPSILON cannot resolve symbol.从这段代码中,我对 sqrt、sin & cos 无法解析方法和 EPSILON 无法解析符号有一些问题。 Do I need to add in math library for the sin cos & sqrt?我需要为 sin cos 和 sqrt 添加数学库吗? If yes can you give me the link to download the jar?如果是的话,你能给我下载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);

You don't have to download any additional libraries.您不必下载任何其他库。 Use Math.sin(x), Math.cos(x) and Math.sqrt(x) or sin(x), cos(x) and sqrt(x) and place the following code at the top of your file (but below the line package [...] , if it exists):使用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;

If you're using Eclipse just press Ctrl + Shift + O to automatically organize your imports (there should be similar shortcuts for other IDE's).如果您使用 Eclipse,只需按Ctrl + Shift + O即可自动组织您的导入(其他 IDE 应该有类似的快捷方式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM