Here you can find the source of clamp(float min, float x, float max)
Parameter | Description |
---|---|
min | The minimum value. |
x | The value. |
max | The maximum value. |
public static float clamp(float min, float x, float max)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . ja v a 2 s. com * Clamps a value between a min and a max, both inclusive. Equivalent to * calling Math.min(max, Math.max(x, min)). * @param min The minimum value. * @param x The value. * @param max The maximum value. * @return The clamped value. */ public static float clamp(float min, float x, float max) { return Math.min(max, Math.max(x, min)); } }