/** 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); }
/** Sets the components from the given spherical coordinate * @param azimuthalAngle The angle between x-axis in radians [0, 2pi] * @param polarAngle The angle between z-axis in radians [0, pi] * @return This vector for chaining */ public Vector3 setFromSpherical (float azimuthalAngle, float polarAngle) { float cosPolar = MathUtils.cos(polarAngle); float sinPolar = MathUtils.sin(polarAngle); float cosAzim = MathUtils.cos(azimuthalAngle); float sinAzim = MathUtils.sin(azimuthalAngle); return this.set(cosAzim * sinPolar, sinAzim * sinPolar, cosPolar); }
/** Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. * @param degrees The angle in degrees. * @return This matrix for the purpose of chaining operations. */ public Affine2 setToRotation (float degrees) { float cos = MathUtils.cosDeg(degrees); float sin = MathUtils.sinDeg(degrees); m00 = cos; m01 = -sin; m02 = 0; m10 = sin; m11 = cos; m12 = 0; return this; }
/** Returns a random item from the array, or zero if the array is empty. */ public char random () { if (size == 0) return 0; return items[MathUtils.random(0, size - 1)]; }
/** 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))); }
/** Reduces the size of the backing arrays to be the specified capacity or less. If the capacity is already less, nothing is * done. If the map contains more items than the specified capacity, the next highest power of two capacity is used instead. */ public void shrink (int maximumCapacity) { if (maximumCapacity < 0) throw new IllegalArgumentException("maximumCapacity must be >= 0: " + maximumCapacity); if (size > maximumCapacity) maximumCapacity = size; if (capacity <= maximumCapacity) return; maximumCapacity = MathUtils.nextPowerOfTwo(maximumCapacity); resize(maximumCapacity); }
public float apply (float a) { return 1 - MathUtils.cos(a * MathUtils.PI / 2); } };
public float apply (float a) { if (a == 0) return 0; a = 1 - a; return (1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale); } }
@Override public int compareTo (Attribute o) { if (type != o.type) return (int)(type - o.type); BlendingAttribute other = (BlendingAttribute)o; if (blended != other.blended) return blended ? 1 : -1; if (sourceFunction != other.sourceFunction) return sourceFunction - other.sourceFunction; if (destFunction != other.destFunction) return destFunction - other.destFunction; return (MathUtils.isEqual(opacity, other.opacity)) ? 0 : (opacity < other.opacity ? 1 : -1); } }
/** Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. * @param degrees The angle in degrees. * @return This matrix for the purpose of chaining operations. */ public Affine2 setToRotation (float degrees) { float cos = MathUtils.cosDeg(degrees); float sin = MathUtils.sinDeg(degrees); m00 = cos; m01 = -sin; m02 = 0; m10 = sin; m11 = cos; m12 = 0; return this; }
/** Returns a random item from the array, or null if the array is empty. */ public T random () { if (size == 0) return null; return items[MathUtils.random(0, size - 1)]; }
/** 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))); }
/** Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many * items to avoid multiple backing array resizes. */ public void ensureCapacity (int additionalCapacity) { if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity); int sizeNeeded = size + additionalCapacity; if (sizeNeeded >= threshold) resize(MathUtils.nextPowerOfTwo((int)Math.ceil(sizeNeeded / loadFactor))); }
public float apply (float a) { return 1 - MathUtils.cos(a * MathUtils.PI / 2); } };
public float apply (float a) { if (a == 0) return 0; a = 1 - a; return (1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale); } }
/** @return True if this matrix has any rotation or scaling, false otherwise */ public boolean hasRotationOrScaling () { return !(MathUtils.isEqual(val[M00], 1) && MathUtils.isEqual(val[M11], 1) && MathUtils.isEqual(val[M22], 1) && MathUtils.isZero(val[M01]) && MathUtils.isZero(val[M02]) && MathUtils.isZero(val[M10]) && MathUtils.isZero(val[M12]) && MathUtils.isZero(val[M20]) && MathUtils.isZero(val[M21])); } }
@Override public int compareTo (Attribute o) { if (type != o.type) return type < o.type ? -1 : 1; float otherValue = ((TestAttribute)o).value; return MathUtils.isEqual(value, otherValue) ? 0 : (value < otherValue ? -1 : 1); } }
/** 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); }