-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);
4

1 回答 1

0

您不必下载任何其他库。使用Math.sin(x), Math.cos(x) and Math.sqrt(x)orsin(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 应该有类似的快捷方式)。

于 2017-02-17T17:18:30.397 回答