/** * Normalize a Vector2f in-buffer. * * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector2(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.normalizeLocal(); setInBuffer(tempVec2, buf, index); vars.release(); }
private void resetPositions() { float xBase = 155; float yBase = 212; Vector2f dir = new Vector2f(xAxis, yAxis); float length = Math.min(1, dir.length()); dir.normalizeLocal(); float angle = dir.getAngle(); float x = FastMath.cos(angle) * length * 10; float y = FastMath.sin(angle) * length * 10; leftStick.setLocalTranslation( xBase + x, yBase + y, 0 ); xBase = 291; dir = new Vector2f(zAxis, zRotation); length = Math.min(1, dir.length()); dir.normalizeLocal(); angle = dir.getAngle(); x = FastMath.cos(angle) * length * 10; y = FastMath.sin(angle) * length * 10; rightStick.setLocalTranslation( xBase + x, yBase + y, 0 ); } }
/** * Normalize a Vector2f in-buffer. * * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector2(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.normalizeLocal(); setInBuffer(tempVec2, buf, index); vars.release(); }
/** * Normalize a Vector2f in-buffer. * * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector2(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.normalizeLocal(); setInBuffer(tempVec2, buf, index); vars.release(); }