private boolean isInRadius(float x, float y, float radius) { Vector2f point = new Vector2f(x, y); // return true if the distance is less than equal to the radius return point.length() <= radius; }
private float calculateHeight(float radius, float heightFactor, float x, float z) { // find percentage for each 'unit' in radius Vector2f point = new Vector2f(x, z); float val = point.length() / radius; val = 1 - val; if (val <= 0) { val = 0; } return heightFactor * val; }
/** * <code>normalize</code> returns the unit vector of this vector. * * @return unit vector of this vector. */ public Vector2f normalize() { float length = length(); if (length != 0) { return divide(length); } return divide(1); }
/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }
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 ); } }
/** * <code>normalize</code> returns the unit vector of this vector. * * @return unit vector of this vector. */ public Vector2f normalize() { float length = length(); if (length != 0) { return divide(length); } return divide(1); }
/** * <code>normalize</code> returns the unit vector of this vector. * * @return unit vector of this vector. */ public Vector2f normalize() { float length = length(); if (length != 0) { return divide(length); } return divide(1); }
/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }
/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }