Here you can find the source of clamp(double v, double lower, double upper)
Parameter | Description |
---|---|
v | the value to clamp. |
lower | The lower bound. |
upper | The upper bound. |
public static double clamp(double v, double lower, double upper)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . j a v a2 s . com * Clamp the value v to lower and upper. * @param v the value to clamp. * @param lower The lower bound. * @param upper The upper bound. * @return The clamped value. */ public static double clamp(double v, double lower, double upper) { return v < lower ? lower : v > upper ? upper : v; } }