Here you can find the source of absClamp(double value, double bounds)
public static double absClamp(double value, double bounds)
//package com.java2s; //License from project: LGPL public class Main { /**//from ww w . j a va 2 s .c om * Clamps a value isBetween -bounds to +bounds * @return A value capped isBetween two bounds. */ public static double absClamp(double value, double bounds) { return min(max(value, -bounds), bounds); } public static float absClamp(int value, int bounds) { return min(max(value, -bounds), bounds); } /** * Returns the smaller number of a and b. * @param a value. * @param b value. * @return min */ public static int min(int a, int b) { return a < b ? a : b; } /** * Returns the smaller number of a, b and c. * @param a value. * @param b value. * @param c value. * @return min */ public static int min(int a, int b, int c) { return min(min(a, b), c); } /** * Returns the smallest number contained in the provided array. * @param numbers Array of numbers * @return min */ public static int min(int... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } int min = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < min) { min = numbers[i]; } } return min; } /** * Returns the smaller number of a and b. * @param a value. * @param b value. * @return min */ public static double min(double a, double b) { return a < b ? a : b; } /** * Returns the smaller number of a, b and c. * @param a value. * @param b value. * @param c value. * @return min */ public static double min(double a, double b, double c) { return min(min(a, b), c); } /** * Returns the smallest number contained in the provided array. * @param numbers Array of numbers * @return min */ public static double min(double... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } double min = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < min) { min = numbers[i]; } } return min; } /** * Returns the smaller number of a and b. * @param a value. * @param b value. * @return min */ public static float min(float a, float b) { return a < b ? a : b; } /** * Returns the smaller number of a, b and c. * @param a value. * @param b value. * @param c value. * @return min */ public static float min(float a, float b, float c) { return min(min(a, b), c); } /** * Returns the smallest number contained in the provided array. * @param numbers Array of numbers * @return min */ public static float min(float... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } float min = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < min) { min = numbers[i]; } } return min; } /** * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static int max(int a, int b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static int max(int a, int b, int c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static int max(int... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } int max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } /** * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static double max(double a, double b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static double max(double a, double b, double c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static double max(double... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } double max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } /** * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static float max(float a, float b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static float max(float a, float b, float c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static float max(float... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } float max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } }