/** Clamps the value to the progress bar's min/max range. This can be overridden to allow a range different from the progress * bar knob's range. */ protected float clamp (float value) { return MathUtils.clamp(value, min, max); }
/** Clamps the value to the progress bar's min/max range. This can be overridden to allow a range different from the progress * bar knob's range. */ protected float clamp (float value) { return MathUtils.clamp(value, min, max); }
public float getVisualScrollPercentX () { if (maxX == 0) return 0; return MathUtils.clamp(visualAmountX / maxX, 0, 1); }
public float getScrollPercentY () { if (maxY == 0) return 0; return MathUtils.clamp(amountY / maxY, 0, 1); }
void clamp () { if (!clamp) return; scrollX(overscrollX ? MathUtils.clamp(amountX, -overscrollDistance, maxX + overscrollDistance) : MathUtils.clamp(amountX, 0, maxX)); scrollY(overscrollY ? MathUtils.clamp(amountY, -overscrollDistance, maxY + overscrollDistance) : MathUtils.clamp(amountY, 0, maxY)); }
void clamp () { if (!clamp) return; scrollX(overscrollX ? MathUtils.clamp(amountX, -overscrollDistance, maxX + overscrollDistance) : MathUtils.clamp(amountX, 0, maxX)); scrollY(overscrollY ? MathUtils.clamp(amountY, -overscrollDistance, maxY + overscrollDistance) : MathUtils.clamp(amountY, 0, maxY)); }
public void writeSamples (float[] samples, int offset, int numSamples) { if (bytes == null || bytes.length < numSamples * 2) bytes = new byte[numSamples * 2]; int end = Math.min(offset + numSamples, samples.length); for (int i = offset, ii = 0; i < end; i++) { float floatSample = samples[i]; floatSample = MathUtils.clamp(floatSample, -1f, 1f); int intSample = (int)(floatSample * 32767); bytes[ii++] = (byte)(intSample & 0xFF); bytes[ii++] = (byte)((intSample >> 8) & 0xFF); } writeSamples(bytes, 0, numSamples * 2); }
public void writeSamples (float[] samples, int offset, int numSamples) { if (bytes == null || bytes.length < numSamples * 2) bytes = new byte[numSamples * 2]; int end = Math.min(offset + numSamples, samples.length); for (int i = offset, ii = 0; i < end; i++) { float floatSample = samples[i]; floatSample = MathUtils.clamp(floatSample, -1f, 1f); int intSample = (int)(floatSample * 32767); bytes[ii++] = (byte)(intSample & 0xFF); bytes[ii++] = (byte)((intSample >> 8) & 0xFF); } writeSamples(bytes, 0, numSamples * 2); }
public void writeSamples (float[] samples, int offset, int numSamples) { if (bytes == null || bytes.length < numSamples * 2) bytes = new byte[numSamples * 2]; int end = Math.min(offset + numSamples, samples.length); for (int i = offset, ii = 0; i < end; i++) { float floatSample = samples[i]; floatSample = MathUtils.clamp(floatSample, -1f, 1f); int intSample = (int)(floatSample * 32767); bytes[ii++] = (byte)(intSample & 0xFF); bytes[ii++] = (byte)((intSample >> 8) & 0xFF); } writeSamples(bytes, 0, numSamples * 2); }
public boolean scrolled (int amount) { if (!Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) return false; duration -= amount / 15f; duration = MathUtils.clamp(duration, 0, Float.POSITIVE_INFINITY); return true; }
/** Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized. * @return the rotation around the x axis in radians (between -(PI/2) and +(PI/2)) */ public float getPitchRad () { final int pole = getGimbalPole(); return pole == 0 ? (float)Math.asin(MathUtils.clamp(2f * (w * x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f; }
/** Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized. * @return the rotation around the x axis in radians (between -(PI/2) and +(PI/2)) */ public float getPitchRad () { final int pole = getGimbalPole(); return pole == 0 ? (float)Math.asin(MathUtils.clamp(2f * (w * x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f; }
public void writeSamples (float[] samples, int offset, int numSamples) { if (bytes == null || bytes.length < numSamples * 2) bytes = new byte[numSamples * 2]; int end = Math.min(offset + numSamples, samples.length); for (int i = offset, ii = 0; i < end; i++) { float floatSample = samples[i]; floatSample = MathUtils.clamp(floatSample, -1f, 1f); int intSample = (int)(floatSample * 32767); bytes[ii++] = (byte)(intSample & 0xFF); bytes[ii++] = (byte)((intSample >> 8) & 0xFF); } writeSamples(bytes, 0, numSamples * 2); }
/** Set this quaternion to the rotation between two vectors. * @param v1 The base vector, which should be normalized. * @param v2 The target vector, which should be normalized. * @return This quaternion for chaining */ public Quaternion setFromCross (final Vector3 v1, final Vector3 v2) { final float dot = MathUtils.clamp(v1.dot(v2), -1f, 1f); final float angle = (float)Math.acos(dot); return setFromAxisRad(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x, angle); }
/** Set this quaternion to the rotation between two vectors. * @param v1 The base vector, which should be normalized. * @param v2 The target vector, which should be normalized. * @return This quaternion for chaining */ public Quaternion setFromCross (final Vector3 v1, final Vector3 v2) { final float dot = MathUtils.clamp(v1.dot(v2), -1f, 1f); final float angle = (float)Math.acos(dot); return setFromAxisRad(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x, angle); }
/** Get the angle in radians of the rotation around the specified axis. The axis must be normalized. * @param axisX the x component of the normalized axis for which to get the angle * @param axisY the y component of the normalized axis for which to get the angle * @param axisZ the z component of the normalized axis for which to get the angle * @return the angle in radians of the rotation around the specified axis */ public float getAngleAroundRad (final float axisX, final float axisY, final float axisZ) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); final float l2 = Quaternion.len2(axisX * d, axisY * d, axisZ * d, this.w); return MathUtils.isZero(l2) ? 0f : (float)(2.0 * Math.acos(MathUtils.clamp( (float)((d < 0 ? -this.w : this.w) / Math.sqrt(l2)), -1f, 1f))); }
@Override public boolean scrolled (int amount) { worldCamera.zoom += amount * 0.01f; worldCamera.zoom = MathUtils.clamp(worldCamera.zoom, 0.01f, 5000); worldCamera.update(); return super.scrolled(amount); }
/** @param smoothing a value between 0 and 1 */ public void setSmoothing (float smoothing) { float delta = 0.5f * MathUtils.clamp(smoothing, 0, 1); setUniformf("u_lower", 0.5f - delta); setUniformf("u_upper", 0.5f + delta); } }
/** Get the angle in radians of the rotation around the specified axis. The axis must be normalized. * @param axisX the x component of the normalized axis for which to get the angle * @param axisY the y component of the normalized axis for which to get the angle * @param axisZ the z component of the normalized axis for which to get the angle * @return the angle in radians of the rotation around the specified axis */ public float getAngleAroundRad (final float axisX, final float axisY, final float axisZ) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); final float l2 = Quaternion.len2(axisX * d, axisY * d, axisZ * d, this.w); return MathUtils.isZero(l2) ? 0f : (float)(2.0 * Math.acos(MathUtils.clamp( (float)((d < 0 ? -this.w : this.w) / Math.sqrt(l2)), -1f, 1f))); }
@Override public boolean scrolled (int amount) { worldCamera.zoom += amount * 0.01f; worldCamera.zoom = MathUtils.clamp(worldCamera.zoom, 0.01f, 5000); worldCamera.update(); return super.scrolled(amount); }