Here you can find the source of clamp(float f)
private static float clamp(float f)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww . j a v a 2s . c om*/ * Clamp the given value to [0, 1] */ private static float clamp(float f) { f = f < 0.0f ? 0.0f : f; f = f > 1.0f ? 1.0f : f; return f; } }