Here you can find the source of clamp01(double value)
public static double clamp01(double value)
//package com.java2s; //License from project: Open Source License public class Main { public static double clamp01(double value) { return clamp(value, 0.0, 1.0); }/*w w w . j a va 2 s . com*/ public static double clamp(double value, double min, double max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } public static int clamp(int value, int min, int max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } }