Here you can find the source of zeroToOne(float value, float min, float max)
public static float zeroToOne(float value, float min, float max)
//package com.java2s; //License from project: Open Source License public class Main { public static float zeroToOne(float value, float min, float max) { return clamp(0.0f, (value - min) / (max - min), 1.0f); }/*from w w w . j av a 2 s . c o m*/ public static double zeroToOne(double value, double min, double max) { return clamp(0.0, (value - min) / (max - min), 1.0); } public static float clamp(float min, float value, float max) { return value < min ? min : value > max ? max : value; } public static double clamp(double min, double value, double max) { return value < min ? min : value > max ? max : value; } }