Here you can find the source of unsignedConstraintValue(double v, double min, double max)
Parameter | Description |
---|---|
v | the value to constraint |
min | the lower bound (only values >= 0 are applied) |
max | the upper bound (only values >= 0 are applied) |
public static double unsignedConstraintValue(double v, double min, double max)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 BestSolution.at and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w . ja va 2 s . co m * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation *******************************************************************************/ public class Main { /** * Constraint the given value to the upper and lower bound * * @param v * the value to constraint * @param min * the lower bound (only values >= 0 are applied) * @param max * the upper bound (only values >= 0 are applied) * @return the value * @since 2.2.0 */ public static double unsignedConstraintValue(double v, double min, double max) { double rv = v; if (min >= 0) { rv = Math.max(rv, min); } if (max >= 0) { rv = Math.min(rv, max); } return rv; } }