Here you can find the source of clip(float x)
Parameter | Description |
---|---|
x | a parameter |
public static float clip(float x)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w. j a v a 2 s. c om*/ * Simple utility function that is used in a couple of places. * * @param x * @return x constrained to [0, 1] */ public static float clip(float x) { return Math.min(Math.max(x, 0), 1); } /** * Simple utility function that is used in a couple of places. * * @param x * @param min * @param max * @return x constrained to [min, max] */ public static float clip(float x, float min, float max) { return Math.min(Math.max(x, min), max); } }