从这段代码我有一些关于sqrt,sin& amp的问题。 cos无法解析方法且EPSILON无法解析符号。我是否需要为sin cos&添加数学库?开方?如果是,你可以给我下载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);
答案 0 :(得分: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应该有类似的快捷方式)。