Here you can find the source of pixelValuesEqual(final double num1, final double num2)
Parameter | Description |
---|---|
num1 | the first value for which to compare equality |
num2 | the second value for which to compare equality |
public static boolean pixelValuesEqual(final double num1, final double num2)
//package com.java2s; /*//from w w w .j ava 2s . c o m * Copyright 2000-2016 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class Main { /** * The allowed value inaccuracy when comparing two double-typed pixel * values. * <p> * Since we're comparing pixels on a screen, epsilon must be less than 1. * 0.49 was deemed a perfectly fine and beautifully round number. */ public static final double PIXEL_EPSILON = 0.49d; /** * Compares two double values with the error margin of * {@link #PIXEL_EPSILON} (i.e. {@value #PIXEL_EPSILON}) * * @param num1 * the first value for which to compare equality * @param num2 * the second value for which to compare equality * @since 7.4 * * @return true if the values are considered equals; false otherwise */ public static boolean pixelValuesEqual(final double num1, final double num2) { return Math.abs(num1 - num2) <= PIXEL_EPSILON; } }