Here you can find the source of clamp(float min, float max, float value)
private static float clamp(float min, float max, float value)
//package com.java2s; //License from project: Open Source License public class Main { private static float clamp(float min, float max, float value) { final float clamp; if (value < min) { clamp = min;/*from ww w .j a va 2 s . c o m*/ } else if (value > max) { clamp = max; } else { clamp = value; } return clamp; } }