Java Code Examples for com.jme3.math.FastMath#acos()
The following examples show how to use
com.jme3.math.FastMath#acos() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CurvesHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * This method transforms the first line of the bevel points positioning it * on the first point of the curve. * * @param startingLinePoints * the vbevel shape points * @param firstCurvePoint * the first curve's point * @param secondCurvePoint * the second curve's point * @return points of transformed bevel */ private Vector3f[] transformToFirstLineOfBevelPoints(Vector3f[] startingLinePoints, Vector3f firstCurvePoint, Vector3f secondCurvePoint) { Vector3f planeNormal = secondCurvePoint.subtract(firstCurvePoint).normalizeLocal(); float angle = FastMath.acos(planeNormal.dot(Vector3f.UNIT_Y)); planeNormal.crossLocal(Vector3f.UNIT_Y).normalizeLocal();// planeNormal is the rotation axis now Quaternion pointRotation = new Quaternion(); pointRotation.fromAngleAxis(angle, planeNormal); Matrix4f m = new Matrix4f(); m.setRotationQuaternion(pointRotation); m.setTranslation(firstCurvePoint); float[] temp = new float[] { 0, 0, 0, 1 }; Vector3f[] verts = new Vector3f[startingLinePoints.length]; for (int j = 0; j < verts.length; ++j) { temp[0] = startingLinePoints[j].x; temp[1] = startingLinePoints[j].y; temp[2] = startingLinePoints[j].z; temp = m.mult(temp);// the result is stored in the array if (fixUpAxis) { verts[j] = new Vector3f(temp[0], -temp[2], temp[1]); } else { verts[j] = new Vector3f(temp[0], temp[1], temp[2]); } } return verts; }